Advertisement
ralphschindler

@jkeppens Select/Where

Jul 27th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. <?php
  2. include '/Users/ralphschindler/Projects/zf2/vendor/autoload.php';
  3.  
  4. use Zend\Db\Sql\Select;
  5. use Zend\Db\Sql\Predicate;
  6.  
  7. $select = new Select;
  8. $select->from('foo');
  9.  
  10. $select->where(['x' => null]);
  11. $select->where(['x' => 5], 'OR');
  12. // OR
  13. $select->where(function ($where) {
  14.     $where->isNull('x')->OR->equalTo('x', 5);
  15. });
  16. $select->where(new Predicate\Expression('x IS NULL or x = ?', 5));
  17.  
  18. echo @$select->getSqlString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement