0
所以我想實現這個查詢:ZF2使用或型號
SELECT `userMessages`.*, `users`.`username` AS `username` FROM `userMessages`
INNER JOIN `users` ON `users`.`id` = `userMessages`.`FROMuID` WHERE
userMessages.FROMuID = 41 AND userMessages.TOuID = 40
OR userMessages.FROMuID = 40 AND userMessages.TOuID = 41 ORDER BY `userMessages`.`messageTime` DESC
這裏是我的模型
public function getUserMessages($uID,$fromUID,$paginated = true){
if($paginated) {
// create a new Select object for the table ads
$select = new Select($this->tableGateway->table);
$select->join('users','users.id = userMessages.FROMuID',array('username'),'inner');
$select->where("userMessages.FROMuID = $fromUID");
$select->where("userMessages.TOuID = $uID");
$select->order('userMessages.messageTime DESC');
// create a new result set based on the Ads entity
$resultSetPrototype = new ResultSet();
// create a new pagination adapter object
$paginatorAdapter = new DbSelect(
// our configured select object
$select,
// the adapter to run it against
$this->tableGateway->getAdapter()
//,
// the result set to hydrate
//$resultSetPrototype
);
$paginator = new Paginator($paginatorAdapter);
return $paginator;
}
$resultSet = $this->tableGateway->select();
return $resultSet;
}
你知道我怎麼能做到這一點?我想我需要在我的語句\Zend\Db\Sql\Predicate\
中使用,但我不知道如何。