Created
February 26, 2013 23:18
-
-
Save ijmorgado/5043284 to your computer and use it in GitHub Desktop.
This is a small piece of code to create a select statement with 2 like clauses connected by "OR". It was made in ZF2. :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$adapter = $this->tableGateway->getAdapter(); | |
$select = new Select(); | |
$select->from('alb_imagen') | |
->columns(array('itemId' => 'id_imagen', | |
'value' => 'titulo')) | |
->limit(12) | |
->join(array('t' => 'alb_thumbnail'),'t.id_imagen = alb_imagen.id_imagen',array('imagen' => 'nombre')) | |
->where('t.tipo = \'MINI_ICON50X50\' and alb_imagen.activo =1') | |
->where(array(new PredicateSet(array(new Like('titulo', "%".$query."%"), | |
new Like('descripcion', "%$query%") | |
), | |
PredicateSet::COMBINED_BY_OR | |
))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
However...if we just want to do a couple of like predicate with AND clause, just need to do:
...all stuff with select object..//
->where->like('titulo', "%".$query."%")->like('descripcion', "%$query%");
..and that will work.