Okay, I think I know why this is happening. Cake doesn't assume that the databases are all on the same server and have the same credentials so it doesn't create multiple database queries like:
SELECT local.shoes.name, global.shoebrands.name FROM local.shoes LEFT JOIN global.shoebrands ON global.shoebrands.id = local.shoebrands.shoebrand_id WHERE global.shoebrands.name LIKE '%nike %' It seems that it just drops anything from the query that isn't in the same database as the primary model being searched. My question now is more specific. Is there some way to override this behavior without hacking cakephp's core? I tried actually putting the database name in the prefix in the database config file, but this is only a prefix for table names. Again, I can see why cakephp does this by default, but there must be some way to specify that these databases belong together. Has anyone gotten this to work? I appreciate any help on this issue. Thank You. On Nov 21, 9:07 am, jmmg77 <[EMAIL PROTECTED]> wrote: > Hi, > > I have been trying to figure this one out for a while. When I do > findAll and try to filter by another associated model it works fine > unless that model is in another database. > > Instead of HABTM, I'm using hasMany and belongsTo. Still, when I try > to filter by a model in another database, I get an error. When I read > the SQL being generated it became obvious why this isn't working. For > some reason, all models in the first database are in the query, but > any models in another database are totally excluded from the query. > > These models that don't show up in the query still show up in the > results. > > An example would be like this. > > DB1: local > DB2: global > > I've got models "individuals", "shoes", "individualshoes" in the local > database. > Then, I've go models "shoetypes", "shoebrands" in the global database. > > My dilema is this: How do I perform a findAll on individuals with > conditions like this "shoebrands.name LIKE '%nike%'". > > I realize that in this example, I would be better off filtering by > shoes.shoebrand_id, but for what I'm doing I need my example to work. > > Basically this example just won't work any way I try unless shoebrands > is in the local database too. Again, I'm not using habtm because I've > found it impossible to filter by different models at all that way. I > am using hasMany, hasOne and belongsTo where appropriate. I am also > using $useDbConfig. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
