我得到確切的錯誤,如獲取錯誤上的Yii像SQLSTATE [HY000]:常規錯誤時間:2014年不能執行查詢,而其他非緩衝查詢是活躍
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 am using Yii framework in my project. OS: Debian GNU/Linux 8 \n \l Php: PHP 5.6.13-0+deb8u1 Mysql: 4.2.12deb2 Database client version: libmysql - 5.5.44
我從數據庫獲取數據和導出爲CSV作爲每下面的代碼:
ini_set('memory_limit', '-1');
$cmd = Yii::app()->db->createCommand("select su.name as ConsultantName , su.Surname as ConsultantSurname,su.RegistrationDate as RegistrationDate,su.CardNumber as ConsultantCardNumber,su.SequenceNumber as ConsultantSequenceNumber,
s.Name as StoreName,s.StoreAddress1 as StoreAddress,s.LeegraCode,s.LeegraRegion as Region , n.Name as Network, sg.Name as SuperGroup,sg.CardNumber as SuperGroupCardnumber,sg.SequenceNumber as SuperGroupSequenceNumber, s.ID as AccelerateID,
manager.Name as StoreManagerName, manager.Surname as StoreManagerSurname, manager.CardNumber as ManagerCardNumber, manager.SequenceNumber as ManagerSequenceNumber,fun_total_claim_by_sustemuser(su.ID) as Total_number_of_claims_ever,fun_systemuser_register(su.ID) as Registered_AND_Activated_Yes_No
from systemuser su
inner join store s on s.ID = su.StoreID
inner join network n on n.ID = su.NetworkID
left join (select man.* from systemuser man inner join store store on store.ID = man.StoreID and RoleID = 3) manager on manager.StoreID = s.ID
inner join supergroup sg on sg.ID = s.SuperGroupID
where su.RoleID = 1");
Yii::import('ext.ECSVExport');
$csv = new ECSVExport($cmd);
$content = $csv->toCSV();
$filename="StoreByUserByNetworkByManager.csv" ;
Yii::app()->getRequest()->sendFile($filename, $content, "text/csv", false);
exit();
此相同的代碼工作我的本地系統上,但新的服務器上不工作,因爲我已經上面給出的信息。 有沒有人知道什麼可能是一個問題得到這個錯誤?
我都嘗試過,但給錯誤樣cdbconnection :: PDO沒有發現 – user1181940
有在回答多餘的空白。我刪除它並更新答案。 – scaisEdge
仍然存在同樣的問題 – user1181940