0

我试图在 ZF2 中使用谓词来查询date名为的类型列column_date

任何专栏似乎都没有任何效果,而且我太新了,我不确定从哪里开始..

        $query = $this->tableGateway->getSql()->select();

        $predicate = new Where();
        $query->where($predicate->equalTo('user_id' , $params['user_id']));
        $query->where($predicate->equalTo('super_type', 'steep'));
        $query->where($predicate->greaterThan('column_date',$dateRangeArray[0]));
        $query->where($predicate->lessThan('column_date', $dateRangeArray[1]));

        $rowset = $this->tableGateway->select($query);
        $resultArr = $rowset->toArray();

这是返回的东西不正确user_id,不正确column_date..为什么?

dateRangeArray看起来像这样:

dateRangeArray[0] = 2014-09-01 dateRangeArray[1] = 2015-09-01

4

1 回答 1

0

这现在在 Apigility 的 TableGateway 中正常工作

    //parses into an array of YYYY-MM-DD
    $dateRangeArray = $transformer->parseDateRange($activity_date_range, "ymd");

    $start_date_formatted = date('Y-m-d', strtotime($dateRangeArray[0]));
    $end_date_formatted = date('Y-m-d', strtotime($dateRangeArray[1]));


    // Query 
    $query = $this->getSql()->select()
        ->where->equalTo('user_id' , $user_id)
        ->where->greaterThanOrEqualTo('field_date ', $start_date_formatted)
        ->where->lessThanOrEqualTo('fieldy_date',$end_date_formatted);


    $rowset = $this->select($query);
    $resultArr = $rowset->toArray();

    return $resultArr;
于 2014-10-06T22:00:33.413 回答