Sunday, July 6, 2014

Re: Using multiple databases with defaultConnectionName

OJ,

Thank you for the response. Unfortunately, i should have specified in the title or in my post that i'm working with CakePHP 3.0 alpha.

The documentation example i linked to is here:
http://book.cakephp.org/3.0/en/orm/table-objects.html#configuring-connections

My connection settings are stored with the other Datasources in App/Config/app.php, and the model is attempting to load, but doesn't seem to know it should use the other database.

i've seen other instructions using the variable you mentioned, but it doesn't seem to apply to v3.0.

Appreciate your time. :)



On Sunday, 6 July 2014 23:38:50 UTC-4, OJ Tibi - @ojtibi wrote:
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: