0

我正在尝试在查找中翻译此查询,但没有成功。我的发现没有返回任何东西。

我的 SQL(在 postgresql 中)

select * from projectversion where project='10003' releasedate>=now()::date or releasedate is null

我的发现

   $projectversions = $this->find('list', array(
            'recursive' => -1,
            'fields' => array('vname'),
            'conditions' => array('project' => $id_project,'releasedate >=now()::date','OR'=>array('releasedate is null'))));

任何人都可以帮助我吗?

4

1 回答 1

1

您原来的 SELECT 似乎无效:

select * from projectversion where project='10003' releasedate>=now()::date or releasedate is null

应该是:

select * from projectversion where project='10003' AND (releasedate>=now()::date or releasedate is null)

如果是这样,您的条件应如下所示:

'conditions'=>array(
    'Model.project'=>10003,
    OR=>array(
        'Model.releasedate >= NOW()'
        'Model.releasedate IS NULL'
    )
)

产生:

WHERE Model.project = 10003 AND (Model.releasedate >= NOW() OR Model.releasedate IS NULL)
于 2013-06-14T15:41:06.390 回答