Hi folks.

This is my first post here. This Group saved me a lot of times (even
when I wasn't member of it), but these days I've been "googling"
around and didn't found a good solution for my problem.

Where I work, we have some integrated databases. All of them in the
same mysql server, but in different schemas. Our users login with the
same username/password for all systems. (Here we work with two
platforms: php and java).

I've used $useDbConfig to use the configuration for the other
database, that was set in /config/database.php.

The problem is: As I experienced, cakePHP can't handle "joins" between
those databases, because instead use a prefix to identify the correct
database, it just create two different connections, and of course, he
can't join them.
My first solution was create a mysql view in the main database of my
application. In this case, cakePHP was able to retrieve the data in
the same connection and join the tables, but I don't know if it's the
best solution for that problem.

My Question: Is there a solution to join these tables in different
databases just using cakePHP, or will I need to use these mysql
views ?!


OBS: In some cases, we don't use cakephp convention, due to this mix
of integrated databases of another systems that doesn't uses cake
convencion, so I needed to set $useTable, and $primaryKey.

This is my /config/database.php:

var $default = array(
                'driver' => 'mysql',
                'persistent' => false,
                'host' => 'localhost',
                'login' => 'root',
                'password' => '',
                'database' => 'cidadaopg',
                'prefix' => '',
        );

        var $gesed = array(
                'driver' => 'mysql',
                'persistent' => false,
                'host' => 'localhost',
                'login' => 'root',
                'password' => '',
                'database' => 'gesed',
                'prefix' => '',
        );


This is my Noticia Model (News in portuguese)

class Noticia extends AppModel{

        var $name = "Noticia";
        var $useTable = "Noticia";
        var $primaryKey = "cd_noticia";

        var $belongsTo = array(
                "CategoriaNoticia" => array(
                        "className" => "CategoriaNoticia",
                        "foreignKey" => "cd_categoria",
                        "type" => "INNER"
                ),
                "Funcionario" => array(
                        "className" => "Funcionario",
                        "foreignKey" => "cd_funcionario",
                ),
        );
}

//---------------------------------------------------------------
My Funcionario Model (employee in portuguese)

class Funcionario extends AppModel{

        var $name = "Funcionario";
        var $useDbConfig = "gesed";
        var $useTable = "Funcionario";
        var $primaryKey = "cd_funcionario";
}


Thanks for the attention and help.

Thiago Elias.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to