multiple mysql connections

88 views
Skip to first unread message

mohd...@gmail.com

unread,
Dec 12, 2012, 9:52:16 PM12/12/12
to frapi-...@googlegroups.com
How can i setup multiple mysql database connections in frapi and how to call it

David Coallier

unread,
Dec 13, 2012, 6:48:00 AM12/13/12
to frapi-...@googlegroups.com
You would have to create a model that manages the creation of those connections then your actions would use the defined model.


On 13 December 2012 02:52, <mohd...@gmail.com> wrote:
How can i setup multiple mysql database connections in frapi and how to call it



--
David Coallier

Louie Miranda

unread,
May 28, 2014, 9:50:47 PM5/28/14
to frapi-...@googlegroups.com, dav...@php.net
Hi,

Posting the answer to help other frapi dev's as well. It's a bit of a hack. But, it works anyway for your needs. Especially, if you want MASTER/SLAVE access.

MASTER
- Insert/Updates

SLAVE
- Read only

So, on your model.

Class, Custom_Model_User

// Normal DB Model
$this->db = Frapi_Database::getInstance(); // LIVE DB

Class, Custom_Model_Slave

// Slave DB Model
$this->db = new PDO('mysql:host=localhost;dbname=frapi2', 'frapi2', 'frapi2'); // SLAVE DB

Hope this helps.

Regards,
Louie
Reply all
Reply to author
Forward
0 new messages