Skip to content

Instantly share code, notes, and snippets.

@matstani
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matstani/9445201 to your computer and use it in GitHub Desktop.
Save matstani/9445201 to your computer and use it in GitHub Desktop.
ZF2 TableGatewayを利用した検索
<?php
$resultSet = $this->tableGateway->select(function ($select) {
$select->where(array(
'id' => 1,
'release_date > ?' => date('Y-m-d', strtotime('-1 year'))
));
$select->where->like('artist', 'The%');
$select->order('artist');
//echo $select->getSqlString($this->tableGateway->getAdapter()->getPlatform());
});
// SELECT `album`.* FROM `album` WHERE `id` = '1' AND release_date > '2013-03-09' AND `artist` LIKE 'The%' ORDER BY `artist` ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment