$db['default'] = array( 'dsn' => "mysql:host=localhost;dbname=test;charset=utf8",//设置数据库连接字符串 'hostname' => 'localhost', 'username' => 'root', 'password' => 'root', 'database' => 'test', 'dbdriver' => 'pdo', //修改数据库驱动 'dbprefix' => 'c_', 'pconnect' => FALSE, 'db_debug' => (ENVIRONMENT !== 'production'), 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE );
function show() { $pdo = $this->db->connect(); //建立对数据库的连接。 $pdo = $this->db->db_pconnect(true); //建立对数据库的连接,使用持久连接 $sql = "select * from c_news"; $res = $pdo->query($sql); $lst = $res->fetchAll(); p($lst); }
标签:PDO,FALSE,utf8,数据库,db,pdo,ci3,连接 From: https://www.cnblogs.com/haokan/p/18386893