致命错误:调用一个成员函数rowCount()在一个非对象在系统\数据库\驱动程序\ pdo \ pdo_result.php在线42

问题描述:

我想在我的CodeIgniter中使用PDO MySQL驱动程序(2.2。 0)应用程序,但我不知道为什么我有这个错误。 这是我的数据库配置:致命错误:调用一个成员函数rowCount()在一个非对象在系统数据库驱动程序 pdo pdo_result.php在线42

$active_group = 'default'; 
$active_record = TRUE; 

$db['default']['hostname'] = 'mysql:host=localhost'; 
$db['default']['username'] = 'root'; 
$db['default']['password'] = ''; 
$db['default']['database'] = 'mydbname'; 
$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; 

调用堆栈

# Time Memory Function Location 
{main}() ..\index.php:0 
require_once('D:\wamp\www\CodeIgniter_2.2.0\system\core\CodeIgniter.php') ..\index.php:202 
3 0.0279 1142584 Login->__construct() ..\CodeIgniter.php:308 
4 0.0279 1142584 CI_Controller->__construct() ..\Login.php:15 
5 0.0308 1338688 CI_Loader->initialize() ..\Controller.php:51 
6 0.0308 1338664 CI_Loader->_ci_autoloader() ..\Loader.php:152 
7 0.0467 2338736 CI_Loader->library() ..\Loader.php:1178 
8 0.0467 2338920 CI_Loader->_ci_load_class() ..\Loader.php:216 
9 0.0487 2471440 CI_Loader->_ci_init_class() ..\Loader.php:975 
10 0.0492 2473816 CI_Session->__construct() ..\Loader.php:1099 
11 0.0521 2574776 CI_Session->sess_read() ..\Session.php:106 
12 0.0541 2580216 CI_DB_active_record->get() ..\Session.php:229 
13 0.0542 2582224 CI_DB_driver->query() ..\DB_active_rec.php:963 
14 0.0566 2670472 CI_DB_pdo_result->num_rows() ..\DB_driver.php:386 

我的默认控制器的login.php:

class Login extends CI_Controller{ 

    function __construct() 
    { 
     parent::__construct(); 

    } 

    function index(){ 
     echo 'hello'; 

    } 
+0

而错误发生的代码是...? –

+0

是不是$ result-> num_rows()而不是$ result-> rowCount() – Luc

+0

我编辑了我的最后一篇文章,显示调用堆栈和我的登录类 – tictactoki

我发现this bug reported against笨2.2.0。

建议的修复方法是避免在CodeIgniter中使用PDO驱动程序,或者升级到CodeIgniter 3.0。