我使用Yii MVC開發代碼,並且我有一個代碼,這是行不通的;Yii createCommand不工作
我找不到錯誤,也許你們可以;
$sql = "
select extension
from file_extension
where status = :status and extension in ('" . $extensions . "');
";
$status = FileExtension::ACTIVE_STATUS; $cmd = Yii::app()->getDb()->createCommand($sql); $cmd->bindParam(":status", $status, PDO::PARAM_INT); $arrObj = $cmd->queryAll();
當我使用print_r($arrObj);
我得到array()
爲什麼我沒有拿到結果?
後的一些工作,我看到我的查詢是這樣的:
選擇擴展 from file_extension where status = :status and extension in ('gif ','pdf ','chm ');
因爲線breakes和空的空間,我的SQL查詢失敗的和;
我能做些什麼來獲得:
選擇擴展 from file_extension where status = :status and extension in ('gif','pdf','chm');
能不能介紹一下你所得到的錯誤詳細點嗎? –
嘗試:Yii :: app() - > db-> createCommand($ sql); –
發生同樣的事情 –