[英]Codeigniter - How can I connect ORACLE, MySQL and SQL Server?
I have found many questions regarding connecting multiple databases like this Link which helps in connecting multiple databases of MYSQL. 我发现了许多有关连接多个数据库的问题,例如此链接 ,它有助于连接多个MYSQL数据库。 In my case i need to connect to MySQL, ORACLE and SQL Server in same application.
就我而言,我需要在同一应用程序中连接到MySQL,ORACLE和SQL Server。
Is it even possible using codeigniter Active Records? 甚至可以使用codeigniter活动记录吗?
I have googled a lot, but was unable to find any answer. 我在Google上搜索了很多,但找不到任何答案。 It was a big surprise for me that no one faced similar problem.
没有人遇到类似的问题,这让我感到惊讶。
I figured out the trick to do this in codeigniter, there are actually three very important things to keep in mind: 我想出了在codeigniter中执行此操作的技巧,实际上要牢记三个非常重要的事情:
$this->sqlsrvr = $this->load->database('test', true); $ this-> sqlsrvr = $ this-> load-> database('test',true);
Example Database.php File 示例Database.php文件
You have to add multiple entries in your database.php file config folder, i am sharing my test database.php file below: 您必须在您的database.php文件配置文件夹中添加多个条目,我在下面共享我的测试database.php文件:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'jawad';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['test']['hostname'] = "192.168.43.104";
$db['test']['username'] = "sa";
$db['test']['password'] = "password";
$db['test']['database'] = "jawad";
$db['test']['dbdriver'] = "sqlsrv";
$db['test']['dbprefix'] = "";
$db['test']['pconnect'] = FALSE;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.