You can clone with
HTTPS or Subversion.
We want to store session data in a SQL Server 2000 database using PDO DBLIB with PHP 5.4.4 in CodeIgniter 2.1.2 and when we setup config and everything we get a PHP error :
Call to a member function fetchAll() on a non-object in /var/www/sites/mysite/system/database/drivers/pdo/pdo_result.php on line 41
In fact the application loads the first time (it creates a session row in the database) but all next requests fail (trying to retrieve data from database fails)
Our setup :
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'Codeigniter_Session';
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent'] = FALSE;
$config['sess_time_to_update'] = 300;
$active_group = 'master';
$active_record = TRUE;
$db['master']['username'] = 'myusername';
$db['master']['password'] = 'mypass';
$db['master']['database'] = 'MyDB';
$db['master']['hostname'] = 'dblib:host=myhostdb'; // important!
$db['master']['dbdriver'] = 'pdo';
$db['master']['dbprefix'] = '';
$db['master']['pconnect'] = TRUE;
$db['master']['db_debug'] = TRUE;
$db['master']['cache_on'] = FALSE;
$db['master']['cachedir'] = '';
$db['master']['char_set'] = 'utf8';
$db['master']['dbcollat'] = 'utf8_general_ci';
$db['master']['swap_pre'] = '';
$db['master']['autoinit'] = TRUE;
$db['master']['stricton'] = FALSE;
Could you enable the profiler, so we can see what the SQL query looks like?
You might want to try with the code from the feature/db_subdrivers branch: https://github.com/EllisLab/CodeIgniter/tree/feature/db_subdrivers
Please share your experience with it if you do, we need some testing done on it.
I tried to enable the profiler, but the error happens before the profiler gets it. But I already made a lot of debugging in CodeIgniter's classes and the error occurs in pdo_result.php so I var_dump the query that was being executed and it looks like this :
WHERE session_id = 'f1803faf2166838addd01c3b46eff7cf'
AND ip_address = '192.168.0.107'
I will try to use the branch for subdrivers, and try to figured out how it works ;-)
Well, as the db_subdrivers branch is based on version 3 of CodeIgniter, erverything breaks in our project, I tried to fix a little but I come up to an error that says : Message: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support getting attributes
It looks like its true that getAttribute is not implemented in DBLIB so it fails even with this version of CodeIgniter
OK, that should be fixed now in feature/db_subdrivers. For 2.1.x however, a fix that doesn't break any other driver would involve a major rewrite of the driver, so IMO it's better off left for 3.0.
@maxiwheat I still haven't tested with the Sessions explicitly, but considering that your issue is related to num_rows(), you can try with this in 2.1: 31380e8
No luck still does not work
Closing this - PDO support in 2.1.x is experimental, so issues with it are expected + MSSQL 2000 is not even supported by Microsoft anymore and even though this is only listed in the 3.0-dev requirements, what we support in CI is MSSQL 2005+.