nasıl symfony / doktrin ve ODBC ile andwhere bir sorun çözebilir?

1 Cevap php

Symfony öğretici (1.4.4) takip ederken, ODBC / mssql 2008 ile birlikte bir hata alıyorum.

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()).'\'');<-- 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();
}

can anyone point me in the right direction? Thanks.

1 Cevap

I "solved it" changing to

$ Q-> andwhere ('j.expires_at> =?', Date ('Ymd 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