Last active
August 29, 2015 13:57
-
-
Save matstani/9445347 to your computer and use it in GitHub Desktop.
ZF2 JOIN検索
This file contains 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
<?php | |
$sm = $this->getServiceLocator(); | |
$adapter = $sm->get('Zend\Db\Adapter\Adapter'); | |
$sql = new \Zend\Db\Sql\Sql($adapter); | |
$select = $sql->select(); | |
$select->from('album'); | |
$select->join( | |
'track', | |
'album.id = track.album_id', | |
array( | |
'trackTitle' => 'title', | |
'duration' | |
) | |
); | |
//echo $select->getSqlString($adapter->getPlatform()); | |
$statement = $sql->prepareStatementForSqlObject($select); | |
$resultSet = $statement->execute(); | |
//SELECT `album`.*, `track`.`title` AS `trackTitle`, `track`.`duration` AS `duration` FROM `album` INNER JOIN `track` ON `album`.`id` = `track`.`album_id` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment