Skip to content

Instantly share code, notes, and snippets.

@ijmorgado
Created February 25, 2013 05:15
Show Gist options
  • Save ijmorgado/5027905 to your computer and use it in GitHub Desktop.
Save ijmorgado/5027905 to your computer and use it in GitHub Desktop.
This is another really good way to make a custom sql query in ZF2 with table gateway in the model...in this case a LIKE statement... :)
$adapter = $this->tableGateway->getAdapter();
$select = new Select();
$select->from('tax_tags')
->limit(5)
->where->like('tag', "%".$query."%");
$statement = $adapter->createStatement();
$select->prepareStatement($adapter, $statement);
$result = $statement->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment