Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthordelia
     
    hi,
    i wanted to relate a model with a database different from the default database, but i dont know where to put the call to the establishConnection method?

    thanks
    •  
      CommentAuthorbermi
     

    Just override the establishConnection method on the special model like

    function &establishConnection()
    {
        return parent::establishConnection('new_namespace_on_the_database_yaml_file');
    }
    

    hope it helps

    • CommentAuthordelia
     
    hi bermi, thanks for your quickly answer. I had done what you said, but where do i put the call to this method? only redefining it doesnt work (there is no call to it anywhere in the framework...)
    •  
      CommentAuthorbermi
     

    Hi Delia,

    If fixed the framework trunk on rev.1249 so it works as documented. After the update previous example will work for you.

    • CommentAuthordelia
     
    hi bermi
    i've updated the framework to rev.1249 where you fixed the connection to different databases, but there is something that doesn't work...

    I have the controller with this models:
    var $models = 'course, inscription"

    Each model is related with a different database, but it seems that the second model tried to access the first one ....

    If i call $this->Course->find(.....) and $this->Inscription->find(...) ...., the second call takes the connection of the previous model (perhaps the framework ask for an open connection, and use the open one (although it's not the correct one...).
    •  
      CommentAuthorbermi
     

    Hi Delia,

    Could you file a ticket for this issue on the trac?

    • CommentAuthordelia
     
    Hi Bermi,
    i've just sent the ticket.
    •  
      CommentAuthorbermi
     

    Delia, I added some unit test for that and fixed some bugs I found on the way. It should work fine now. Check out rev.1252

    • CommentAuthordelia
     
    hi Bermi,
    i have tested with rev 1252 but one of the errors i got is still there:

    if i have in a controller this code:

    var $models = 'inscription, course '; // <- each model is associated with a different database

    function index()
    {

    $this->inscriptions = $this->Inscription->find("all");
    $this->courses = $this->Course->find("all");
    }

    It always take the connection of the first model i have put in the $models var.....

    thanks