Calling consecutive Stored Procedure with PDO DBLIB drivers fails to return results #1606

maxiwheat opened this Issue Jul 11, 2012 · 4 comments


None yet

2 participants


We use PDO DBLIB driver to connect to our SQL Server 2000 instance. Until now everything worked well because we did not attempt to call many Stored Procedures in a same context. However, here is what happens when we make calls like that :

$query = $this->db_client->query("EXEC dbo.stored_procedure1 ?", array($id) );
$result1 = $query->result_array();

$query = $this->db_client->query("EXEC dbo.stored_procedure2 ?", array($id2) );
$result2 = $query->result_array();

$query = $this->db_client->query("EXEC dbo.stored_procedure3");
$result3 = $query->result_array();

var_dump($result2, $result3);

$result1 returns 1 row, $result2 and $result3 are supposed to have one row each in it, but they get empty. If I move the code for calling stored_procedure3 first I get the result but following calls return empty ... so only the first call gets the results. I guess it's a bug in CodeIgniter's db classes which makes consecutive calls fail.

For your information, database config looks like this :

$db['db_client']['username'] = 'myusername';
$db['db_client']['password'] = 'mypassword';
$db['db_client']['database'] ='mydb';
$db['db_client']['hostname'] = 'dblib:host=mydbhost';
$db['db_client']['dbdriver'] = 'pdo';
$db['db_client']['dbprefix'] = '';
$db['db_client']['pconnect'] = TRUE;
$db['db_client']['db_debug'] = TRUE;
$db['db_client']['cache_on'] = FALSE;
$db['db_client']['cachedir'] = '';
$db['db_client']['char_set'] = 'utf8';
$db['db_client']['dbcollat'] = 'utf8_general_ci';
$db['db_client']['swap_pre'] = '';
$db['db_client']['autoinit'] = TRUE;
$db['db_client']['stricton'] = FALSE;
narfbg commented Jul 11, 2012

Well, that's odd. Does it happen with non-stored procedure calls?


We don't use non-stored procedures because it also fails and our system is currently built using only Stored Procedures. When we call ->query with a SELECT, we get this error : Call to a member function fetchAll() on a non-object

narfbg commented Jul 11, 2012

You shouldn't get that with 31380e8 (as referenced in #1578). Other than that and what's done in develop - I'm out of ideas.

You really should upgrade your database to at least MSSQL 2008. If there's any reason that the mssql and pdo_dblib extensions still exist in PHP >= 5.3 - it's because you can't use the SQLSRV variant on UNIX-based systems yet (you probably know that they're no longer available for Windows).
As soon as SQLSRV gets ported, I'd bet my money that mssql and pdo_dblib will at least be deprecated in the next PHP version.

narfbg commented Oct 31, 2013
@narfbg narfbg closed this Oct 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment