本文整理匯總了PHP中Zend\Db\TableGateway\TableGateway::select方法的典型用法代碼示例。如果您正苦於以下問題:PHP TableGateway::select方法的具體用法?PHP TableGateway::select怎麽用?PHP TableGateway::select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Db\TableGateway\TableGateway
的用法示例。
在下文中一共展示了TableGateway::select方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getWarstatus
/**
* Retrieves an Account with the warstatus
* @param int $account_id
* @return null|Warstatus
*/
public function getWarstatus(int $id)
{
$rowset = $this->tableGateway->select(function (Select $select) use($id) {
$select->where(['id' => $id]);
});
$row = $rowset->current();
return $row;
}
示例2: getComment
/**
* Returns a comment by id.
*
* @param int $id
* @return \RbComment\Model\Comment
*/
public function getComment($id)
{
$id = (int) $id;
$rowset = $this->tableGateway->select(array('id' => $id));
$row = $rowset->current();
return $row;
}
示例3: getApplicationCountLast30Days
public function getApplicationCountLast30Days()
{
$dateNow = new \DateTime();
$dateBehind = (new \DateTime())->sub(new \DateInterval('P30D'));
return $this->tableGateway->select(function (Select $select) use($dateNow, $dateBehind) {
$select->where->between('date_applied', $dateBehind->format('Y-m-d H:i:s'), $dateNow->format('Y-m-d H:i:s'));
})->count();
}
示例4: getByUserId
/**
* @param int $id
* @param int $limit
* @param int $offset
*
* @return \Zend\Db\ResultSet\ResultSet
*/
public function getByUserId($id, $limit = 10, $offset = 0)
{
$id = (int) $id;
$rows = $this->tableGateway->select(function (Select $select) use($id, $limit, $offset) {
$select->where(array('user_id' => $id))->limit($limit)->offset(0)->order('news_id DESC');
});
return $rows;
}
示例5: getCityById
/**
* @param $id
* @return City|null
*/
public function getCityById($id)
{
$city = $this->cityTable->select(['ID' => $id]);
if ($city->count() < 1) {
return null;
}
return $city->current();
}
示例6: getByToken
/**
* @param $token
*
* @return User
* @throws \Exception
*/
public function getByToken($token)
{
$rows = $this->tableGateway->select(array('token' => $token));
$row = $rows->current();
if (!$row) {
throw new \Exception("Could not find row " . $token);
}
return $row;
}
示例7: getWarlog
/**
*
* @param string|int $id
*
* @return array|\ArrayObject|null the account with the given id
*/
public function getWarlog()
{
$rowset = $this->tableGateway->select([1]);
$row = $rowset->current();
if (!$row) {
return null;
}
return $row;
}
示例8: getNewsCategoryBy
/**
* Returns the data requested by the array. Key of array must be column name of Account table and $value the actual value
* @param array $array with one [key => value] pair
*
* @return array|\ArrayObject|null|Account the account with the given email
*/
public function getNewsCategoryBy($array)
{
$rowset = $this->tableGateway->select($array);
$row = $rowset->current();
if (!$row) {
return null;
}
return $row;
}
示例9: getCategoryById
public function getCategoryById($id)
{
$rowset = $this->tableGateway->select(array('id_category' => $id));
$row = $rowset->current();
if (!$row) {
throw new \Exception("Could not find row with id {$id}");
}
return $row;
}
示例10: fetch
/**
* @param Request $request
* @param Response $response
* @param $args
*
* @return ResponseInterface
*/
public function fetch(Request $request, Response $response, $args)
{
try {
$result = $this->gateway->select(['id' => 1])->current();
return $response->withJson($result->getArrayCopy(), 200);
} catch (\Exception $e) {
return $response->withStatus(400);
}
}
示例11: getCurrentVersion
public function getCurrentVersion()
{
$result = $this->tableGateway->select(function (Select $select) {
$select->order('version DESC')->limit(1);
});
if (!$result->count()) {
return 0;
}
return $result->current()->getVersion();
}
示例12: getForm
public function getForm($id)
{
$id = (int) $id;
$rowset = $this->tableGateway->select(array('id' => $id));
$row = $rowset->current();
if (!$row) {
throw new \Exception("Could not find row {$id}");
}
return $row;
}
示例13: findAll
/**
*
* @return Contact[]
*/
public function findAll()
{
$rowset = $this->gateway->select();
$results = [];
foreach ($rowset as $row) {
$contact = new Contact();
$this->hydrator->hydrate((array) $row, $contact);
$results[] = $contact;
}
return $results;
}
示例14: read
/**
* {@inheritdoc}
*
* {@inheritdoc}
*/
public function read($id)
{
$this->checkIdentifierType($id);
$identifier = $this->getIdentifier();
$rowset = $this->dbTable->select(array($identifier => $id));
$row = $rowset->current();
if (isset($row)) {
return $row->getArrayCopy();
} else {
return null;
}
}
示例15: dbMultiAction
/**
* @return \Zend\View\Model\JsonModel
*/
public function dbMultiAction()
{
/* @var $request \Zend\Http\Request */
$request = $this->getRequest();
$queries = $request->getQuery('queries', 1);
$worlds = array();
for ($i = 0; $i < $queries; $i += 1) {
foreach ($this->tableGateway->select(array('id' => mt_rand(1, 10000))) as $found) {
$worlds[] = $found;
}
}
return new JsonModel($worlds);
}