gpt4 book ai didi

php - 使用 Pdo 的 Codeigniter 发出对成员函数 rowCount() 的调用

转载 作者:行者123 更新时间:2023-11-29 11:29:06 25 4
gpt4 key购买 nike

我已经使用了 codeigniter 2.2.0,并且想要使用 pdo db 连接与 pdo 驱动程序,但收到类似这样的错误,所以有人能弄清楚我在这里缺少什么吗?

$active_group = 'default';
$active_record = TRUE;
$db['default']['dsn'] = '';
$db['default']['hostname'] = 'mysql:host=192.168.1.222;dbname=test';
$db['default']['username'] = 'admin';
$db['default']['password'] = 'admin';
$db['default']['database'] = 'test';
$db['default']['dbdriver'] = 'pdo';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

此后,当我运行项目时,出现了这个 fatal error fatal error :在第 42 行/opt/lampp/htdocs/collegelife/system/database/drivers/pdo/pdo_result.php 中的非对象上调用成员函数 rowCount()

最佳答案

使用Mysqli而不是 PDO。 原因 Check Sarty's comment on the question

As well Don't use mysql. Its deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0

<小时/>

设置 MySQLi

$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'database_name',
'dbdriver' => 'mysqli',
'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()
);

关于php - 使用 Pdo 的 Codeigniter 发出对成员函数 rowCount() 的调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37719528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com