CamusHsu - 2018-03-19 09:25:47
Dear Sir,
I need to query in foreach, the code as below
$rs = $db->query("SELECT * FROM `member` WHERE 1;");
foreach ($rs as $load){
$rs2 = $db->query("SELECT SUM(`reward_point`) total_point FROM `reward` WHERE `mem_id`='".$load['mem_id']."' GROUP BY `mem_id`;")
}
it display some error message as below
Error: 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.
I found the answer by google, I know that I can use closeCursor to solve the problem. But I don't know how to use closeCursor in your class.
May you help me to solve the issue?
Thank you!
Camus