Set database config at login

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Set database config at login

Olivier CHEMIN
Hi all,

I have an app wich uses multiple databases. 

One database ('default') for common information, users, companies, etc. The login function from the usersController uses this database. 

The rest of the data is stored into another database (let say a company_db_name), so after the user has logged in i would like to create the connection for this company_db_name and keep it available for the whole user session.

I have tried different ways of doing this but it seems i have reached an impass... 

Any idea of a nice cakephp way to do this ?

Thanks !

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Set database config at login

Andras Kende
http://book.cakephp.org/2.0/en/models/model-attributes.html

app/Config/database.php
class DATABASE_CONFIG {
        public $default = array(  
        …………………
        );
        public $company_db_name = array(  
        ………………...
        );
}

app/Model/Example.php
class Example extends AppModel {
        public $useDbConfig = 'company_db_name';
}

Andras Kende
http://www.kende.com

On Sep 12, 2013, at 1:57 AM, Olivier CHEMIN <[hidden email]> wrote:

> Hi all,
>
> I have an app wich uses multiple databases.
>
> One database ('default') for common information, users, companies, etc. The login function from the usersController uses this database.
>
> The rest of the data is stored into another database (let say a company_db_name), so after the user has logged in i would like to create the connection for this company_db_name and keep it available for the whole user session.
>
> I have tried different ways of doing this but it seems i have reached an impass...
>
> Any idea of a nice cakephp way to do this ?
>
> Thanks !
>
> --
> 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 [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.