Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
maxiwheat opened this Issue · 4 comments

2 participants

@maxiwheat

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
Owner

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

@maxiwheat

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
Owner

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.

@moura137 moura137 referenced this issue from a commit
@moura137 moura137 Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into …
…develop

* 'develop' of git://github.com/EllisLab/CodeIgniter: (152 commits)
  Enable travis for feature/* branches
  Improve the solution for issue #1631
  Updated .htaccess files with Apache 2.4+ safe deny statements. Fixes #1631
  Fix on _update_batch() : wrong variable used for field selection
  Inconsistency between log_message and show_error when encountering a non-existant class
  Changed TRUE and FALSE values to be uppercase
  Changed double quotes to single quotes to meet style guidelines
  Fix in index.php inline documentation
  Some adjustments in inline documentation
  Loader::model() - rename foreach ($model AS $single_model) to ($model AS $class). Consistent with ::library() and ::_ci_load_class()
  Add a changelog entry for issue #1605 (pull #1606) and remove some spaces
  fix issue #1605 covert page number type from float to int
  Rename $babe => $single_model, in foreach ($model AS $babe) {...}
  escape_identifiers() to not escape string literals inside double quotes as well
  Fix issue #1613
  Added data-ci-pagination-page="x" to pagination output so JS frameworks can hook on.
  Update develop
  Update develop
  Fix some spaces here
  again... new lines
  ...
fe93b0d
@narfbg narfbg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.