Quantcast

How to set database.config infos using an consult from database postgres on CakePHP?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to set database.config infos using an consult from database postgres on CakePHP?

Edson Rodrigues

I want to set the database config from CakePhP 2.x with data from database


Example - database.config:


public $bd_test = array (
        'datasource' => 'Database/Postgres',
        'persistent' => false,
        'host' => 'localhost',
        'login' => 'root',
        'password' => 'root',
        'database' => 'bd_test',
        'port' => '5432',
        //'encoding' => 'UTF-8'
);

Should looks like:


(I Know That I Cant Do THIS, It's Just To Have an Idea)

$dataFromDb = $this->Model->find('all', array('fields' => array('host', 'login', 'password', 'database', 'port'), 'conditions' => array('database' => 'bd_test')));


public $bd_test = array (
        'datasource' => 'Database/Postgres',
        'persistent' => false,
        'host' => $dataFromDb['host'],
        'login' => $dataFromDb['login'],
        'password' => $dataFromDb['password'],
        'database' => $dataFromDb['database'],
        'port' => '5432',
        //'encoding' => 'UTF-8'
);

Something like that.. I guess that the Idea is clear, right? If need some more information, please tell me. 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 https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Loading...