Yii Framework Forum: Issue while executing few SQL queries in a row - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Issue while executing few SQL queries in a row SQLSTATE[HY000]: General error: 2014 Cannot execute queries while othe Rate Topic: -----

#1 User is offline   Karasko 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 14-July 09
  • Location:Russia

Posted 01 October 2009 - 09:20 AM

Hi everyone )

Running this peace of code
$id = $_GET['id'];
		// get current menu order
		$sql = "SELECT menuOrder FROM categories WHERE id = $id ";
		
		$cmd =  app()->db->createCommand($sql);
		/*@var $cmd CDBCommand */
		//$cmd->bindValue('id',$id);
		$menuOrder = $cmd->queryScalar();
		
		
		$oldMenuOrder = $menuOrder + 1;
		
		// get id of next 
		$sql1 = "UPDATE categories SET menuOrder = menuOrder -1 WHERE menuOrder = $menuOrder +1 ";
		app()->db->createCommand($sql)->execute();
		 
		$sql2 = "UPDATE categories SET menuOrder = $oldMenuOrder WHERE id = $id";
		app()->db->createCommand($sql)->execute();

I gets an error:

Quote

CDbCommand could not execute SQL-query: SQLSTATE[HY000]: General error: 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.


Platform Winxp, php 5.3.0, MySql 5.1.39-community, i gets this error while running few queries to database in a row, it doesn't happen if close connection after each query, and then create the new database connection. But i recieved this error on earlier PHP versions, and MySql...

Anyone had this issue ? While running my code on hosting i don't get any issues doing few SELECT, UPDATE, TRUNCATE statements in a row. While under WINXP it ruins by "executing unbuffered queries". They advise to use PDO::MYSQL_ATTR_USE_BUFFERED_QUERY constant. Where to put this in a case of Yii config ?

Thank you.
0

#2 User is offline   Karasko 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 14-July 09
  • Location:Russia

Posted 02 October 2009 - 05:28 PM

My stupidity )

I try to execute() first 'SELECT' query after...

SOLVED
0

#3 User is offline   Rajib Rakhmit 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 10-October 11
  • Location:Bangladesh

Posted 22 October 2011 - 02:10 AM

View PostKarasko, on 02 October 2009 - 05:28 PM, said:

My stupidity )

I try to execute() first 'SELECT' query after...

SOLVED


Would you plz tell how to solved this problem
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users