Sunday, July 6, 2014

Re: Using multiple databases with defaultConnectionName

Hi, Joe.

First, make sure your other database's connection settings are saved in database.php

Then, in your Captcha model, set the public attribute $useDbConfig to the name of the settings in database.php.

HTH.


On Monday, July 7, 2014 1:18:19 AM UTC+8, Joe Theuerkauf wrote:
Maybe i'm getting in over my head, but i'm trying to learn as much as i can...

i'm attempting to keep a few tables in a different database. My current project will use them, but i want them to be more generally available for other projects down the road (things like mime-types, captcha questions, etc.)... i can see a tiny bit of [documentation] on using defaultConnectionName in the Table class, and i see where it's used in the [ORM/TableRegistry]. So i've set up a Datasource entry in App/Config/app.php, and my Table class is like so:

class CaptchasTable extends Table {
    public static function defaultConnectionName() {
        return 'websites';
    }
}

When i load the page that calls this up, i get this:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'kodiak.captchas' doesn't exist

i'm actually amazed i got that far, but i'm stuck since the CaptchasTable is supposed to connect to the other database and provide 'websites.captchas'.

Thanks for any help.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: