PHP Codeigniter 框架支持 SQL Server
栏目: PHP · SQL Server · 码农笔记 · 发布时间: 8年前
内容简介:PHP Codeigniter 框架支持 SQL Server
数据库配置
// mysql 配置
$db['default'] = array(
'db_type'=>'mysql',
'hostname' => 'localhost',
'username' => 'www.codercto.com',
'password' => 'www.codercto.com',
'database' => 'www.codercto.com',
'dbdriver' => 'pdo',
'port' => '3306',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array()
);
// sql server 配置
$db['default'] = array(
'db_type'=>'sqlsrv',
'hostname' => 'localhost',
'username' => 'www.codercto.com',
'password' => 'www.codercto.com',
'database' => 'www.codercto.com',
'dbdriver' => 'pdo',
'port' => '3341',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array()
);
设置 dsn 信息
foreach($db as &$value)
{
if($value['sqlsrv'] == 'sqlsrv')
{
$value['dsn'] = "sqlsrv:Server={$value['hostname']},{$value['port']};Database={$value['database']}";
}
else
{
$value['dsn'] = "mysql:host={$value['hostname']};port={$value['port']};dbname={$value['database']}";
}
}
这样就可以和使用 mysql 一样使用 SQL Server 了
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Distributed Systems
Sukumar Ghosh / Chapman and Hall/CRC / 2014-7-14 / USD 119.95
Distributed Systems: An Algorithmic Approach, Second Edition provides a balanced and straightforward treatment of the underlying theory and practical applications of distributed computing. As in the p......一起来看看 《Distributed Systems》 这本书的介绍吧!