这是我的代码:
$ptoRequests = CalendarRequest::model()
->with(array('intervals'))
->findAll(array('order' => 't.time, t.id desc',
'condition' => 'eventId in (5, 7, 8, 9, 10, 11) and statusId in (1,2) and userId = "' . $user->userId . '" and (intervals.enddate >= :from)',
'params' => array('from' => date("Y-m-d"))));
echo "<pre>"; var_dump($ptoRequests->getQuery()); echo "</pre>"; exit();
我想要实现的是打印最后执行的查询。 getQuery()函数返回一个致命错误。我该怎么办 ?谢谢
答案 0 :(得分:1)
试试这个
echo ModelClassName::model()->
getCommandBuilder()->
createFindCommand('table_name', $criteria)->text;
其中$条件是
$criteria= new CDbCriteria();
$criteria->condition="your query condition";
$criteria->order="t.time desc"
检查CDbCriteria here以供参考