how can I solve a issue with andWhere with symfony/doctrine and odbc?
While following the symfony tutorial (1.4.4) I'm getting an error with ODBC/mssql 2008.
SQLSTATE[07002]: COUNT field incorrect: 0 [Microsoft][SQL Server Native Client 10.0]COUNT field incorrect or syntax error (SQLExecute[0] at ext\pdo_odbc\odbc_stmt.c:254). Failing Query: "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] > ?) ORDER BY [j].[expires_at] DESC"
I've narrowed the problem to a line that uses parameters
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()).'\'');<-- t开发者_JS百科his 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();
}
can anyone point me in the right direction? Thanks.
I "solved it" changing to
$q->andWhere('j.expires_at >=?', date('Y-m-d H:i:s' time()));
Its a temporary solution, and it works for, now, but i'd like to know why it doesn't works with only the >. Thanks
精彩评论