在遵循 symfony 教程 (1.4.4) 时,我收到 ODBC/mssql 2008 错误。
SQLSTATE[07002]:COUNT 字段不正确:0 [Microsoft][SQL Server Native Client 10.0]COUNT 字段不正确或语法错误(ext\pdo_odbc\odbc_stmt.c:254 处的 SQLExecute[0])。查询失败:“SELECT [j].[id] AS [j__id], [j].[category_id] AS [j__category_id], [j].[type] AS [j__type], [j].[company] AS [ j__company], [j].[logo] AS [j__logo], [j].[url] AS [j__url], [j].[position] AS [j__position], [j].[location] AS [j__location] , [j].[description] AS [j__description], [j].[how_to_apply] AS [j__how_to_apply], [j].[token] AS [j__token], [j].[is_public] AS [j__is_public], [ j].[is_activated] AS [j__is_activated], [j].[email] AS [j__email], [j].[expires_at] AS [j__expires_at], [j].[created_at] AS [j__created_at], [j] .[updated_at] AS [j__updated_at] FROM [jobeet_job] [j] WHERE ([j].[category_id] = '2' AND [j].[expires_at] >
我已将问题缩小到使用参数的行
public function getActiveJobs(Doctrine_Query $q = null)
{
if (is_null($q))
{
$q = Doctrine_Query::create()
->from('JobeetJob j');
}
//$q->andWhere('j.expires_at > \''.date('Y-m-d H:i:s', time()).'\'');<-- this works
$q->andWhere('j.expires_at > ?', date('Y-m-d H:i:s', time())); //<-- this line has problem
$q->addOrderBy('j.expires_at DESC');
return $q->execute();
}
谁能指出我正确的方向?谢谢。