Re: Joins across tables?
It works for me:
class Country extends AppModel {
var $useDbConfig = 'iso';
}
class Address extends AppModel {
var $useDbConfig = 'default';
var $belongsTo = array(
'Country' => array(
'className' => 'Country'
)
);
}
Whenever I access the Address table, CakePHP sends two separate SQL
queries. The first query retrieves all the addresses matching the
conditions, the second query retrieves all the countries for those
addresses. It then assembles the results into the array.
But so far I've only used the $belongsTo, and I'm using Cake's
"automagic".
Check if you are using a custom query.
On Feb 11, 7:00 pm, "Krissy Masters" <naked.cake.ba...@gmail.com>
wrote:
> Just curious if joins across database tables are supposed to work? Same
> server just different databases.
>
> Set up my
>
> public $useDbConfig = 'dataDb';
> public $useDbConfig = 'optiDb'; (in each model depending on its db
> obviously) but now queries come across
>
> SQL Error: 1146: Table 'dev_lab.categories' doesn't exist
>
> If I go to category page its there no errors because that page has no joins
> across db's. But a controller / page where categories has joins with a model
> in another db I get the missing error.
>
> Any insight?
>
> Thanks
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home