• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

I desperately required help please help me its urgent. I am using Codeigniter 3.1 Version and trying to use MySQL 5.5. When I am calling Stored Procedure back to back 2 times its giving the error. Anybody know how to fix this ? **** code ****************

public function foo()
echo "called sp1 <br>";
$sql = "CALL test_sp()";
$query = $this->db->query($sql);
var_dump( $query->result());

echo "<br> called sp2 <br>";
$sql2 = "CALL test1_sp()";
$query2 = $this->db->query($sql2);
********** out put ***********

Error Number: HY000/2014

Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.

CALL test1_sp() Filename: controllers/Test.php Line Number: 27

I even tried out unbuffered row() but it still fails.
while ($row = $query->unbuffered_row())
{ var_dump($row);

I tried setting pdo attribues like system/database/drivers/pdo/pdo_driver.php

public function db_connect($persistent = FALSE)
try {
return new PDO($this->dsn, $this->username, $this->password, $this->options);

No success all my data is coming from mysql stored procedure its not even containing the large result set.

I need to call two stored procedure one after another and it was giving me the error.
I solved this by using the following code.

$sql = "CALL test_sp()";
$stmt = $this->db->conn_id->prepare($sql);
$result = $stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);

We can use any Select statement instead of Stored Procedure only thing is to use in try catch

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.