开发者

FuelPHP and Multiple Database Connections

开发者 https://www.devze.com 2023-04-12 14:44 出处:网络
The FuelPHP documentation does not include information on how to use the DB class to specify connections, which would allow me to then control multiple database connections.Any idea on how to accompli

The FuelPHP documentation does not include information on how to use the DB class to specify connections, which would allow me to then control multiple database connections. Any idea on how to accomplish this? Google search shows evidence of a Database_Connection class, but no infor开发者_运维问答mation on how it might be used.


First place to start would be reading https://github.com/fuel/core/blob/1.1/master/classes/database/connection.php .. It looks like you will have to write something similar to:

$db2 = DB::instance( 'second_connection' );

Where second_connection is configured as per example : http://fuelphp.com/docs/classes/database/introduction.html

When you first time you execute that function, it will create new instance. Afterwards when you use the same line , it will just pick opened connection from the registry .. Essentially, it's same old procedural code with global array of DB connections, just wrapped in fake OO code.

0

精彩评论

暂无评论...
验证码 换一张
取 消