4

I need to add special operators to my query. Query:

SELECT "contests".*
FROM "contests" WHERE "status" = '-1' 
AND "level1" = '1' AND "level2" = '1' AND "level3" = '1' AND "level10" = '1' 
AND DATE(`contests`.`start`) >= '2012-03-17' AND DATE(`contests`.`stop`) <= '2013-12-20'

In Zend Framework 2:

$from = '2012-03-17';
$to = '2013-12-20';
  $sql = new Sql($this->adapter);
  $select = $sql->select('contests')
     ->where($where, $combination = new Predicate\Operator($from, Predicate\Operator::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $to));

But this doesn't work.

2 Answers 2

5

What about if you write your where clause like this:-

$select->where->equalTo('status', '-1'); 
$select->where->equalTo('level1', '1'); 

and etc

$select->where->greaterThanOrEqualTo('start', '2012-03-17');
$select->where->greaterThanOrEqualTo('stop', '2013-12-20');
Sign up to request clarification or add additional context in comments.

1 Comment

is there a lessThanOrEqualTo function ?
1

I am using table gateway. It is more clear to use. you can use where clause.

public function getGelecek()
{
    $select = $this->tableGateway->getSql()->select();
    $select->where(array('active' => '1'));
    $select->where->greaterThan('tarih', '123');
    $resultset = $this->tableGateway->selectWith($select);
    return $resultset;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.