Welcome Guest, Not a member yet? Register   Sign In
how to set PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
#1

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()
{
//test_sp,test1_sp;
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);
var_dump($query2->result());
}
********** 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
Reply
#2

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 {
$this->options[PDO::MYSQL_ATTR_USE_BUFFERED_QUERY] = FALSE;
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.
Reply
#3

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);
var_dump($result);

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




Theme © iAndrew 2016 - Forum software by © MyBB