本文整理汇总了PHP中Zend\Db\TableGateway\TableGateway类的典型用法代码示例。如果您正苦于以下问题:PHP TableGateway类的具体用法?PHP TableGateway怎么用?PHP TableGateway使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TableGateway类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveCommandeProduit
public function saveCommandeProduit($id, $ajouterCommande, $prixproduit)
{
$data = array('COMMANDE_ID' => $id, 'PRODUIT_ID' => $ajouterCommande, 'COMMANDEPRODUIT_PRIX' => $prixproduit);
$adapter = $this->tableGateway->getAdapter();
$otherTable = new TableGateway('commandeproduit', $adapter);
$otherTable->insert($data);
}
示例2: save
/**
* Save Role
*
* @return integer
*/
public function save()
{
$this->events()->trigger(__CLASS__, 'before.save', $this);
$arraySave = array('name' => $this->getName(), 'description' => $this->getDescription());
try {
$roleId = $this->getId();
if (empty($roleId)) {
$this->insert($arraySave);
$this->setId($this->getLastInsertId());
} else {
$this->update($arraySave, array('id' => $this->getId()));
}
$permissions = $this->getPermissions();
if (!empty($permissions)) {
$aclTable = new TableGateway('user_acl', $this->getAdapter());
$aclTable->delete(array('user_acl_role_id' => $this->getId()));
foreach ($permissions as $permissionId => $value) {
if (!empty($value)) {
$aclTable->insert(array('user_acl_role_id' => $this->getId(), 'user_acl_permission_id' => $permissionId));
}
}
}
$this->events()->trigger(__CLASS__, 'after.save', $this);
return $this->getId();
} catch (\Exception $e) {
$this->events()->trigger(__CLASS__, 'after.save.failed', $this);
throw new \Gc\Exception($e->getMessage(), $e->getCode(), $e);
}
}
示例3: fetchAll
/**
* @param bool $paginated
* @param string $filter
* @param string $orderBy
* @param string $order
* @return \Zend\Db\ResultSet\ResultSet|\Zend\Paginator\Paginator
* @throws \Exception
*/
public function fetchAll($paginated = false, $filter = '', $orderBy = 'attendanceDate', $order = 'DESC')
{
if ($paginated) {
return $this->paginate($filter, $orderBy, $order, $this->boardView);
}
$attendanceBoard = new TableGateway($this->boardView, $this->adapter);
return $attendanceBoard->select();
}
示例4: fetchAll
/**
* @param bool $paginated
* @param string $filter
* @param string $orderBy
* @param string $order
* @return \Zend\Db\ResultSet\ResultSet
* @throws \Exception
*/
public function fetchAll($paginated = false, $filter = '', $orderBy = 'contractBy', $order = 'ASC')
{
if ($paginated) {
$this->paginate($filter, $orderBy, $order);
}
$contractView = new TableGateway($this->table, $this->adapter);
return $contractView->select(array('contract' => $this->staffId));
}
示例5: fetchAll
/**
* @param bool $paginated
* @param string $filter
* @param string $orderBy
* @param string $order
* @return \Zend\Db\ResultSet\ResultSet|Paginator
* @throws \Exception
*/
public function fetchAll($paginated = false, $filter = '', $orderBy = 'name', $order = 'ASC')
{
$view = 'vw_hr_position';
if ($paginated) {
return $this->paginate($filter, $orderBy, $order, $view);
}
$tableGateway = new TableGateway($view, $this->adapter);
return $tableGateway->select();
}
示例6: fetchAll
/**
* @param bool $paginated
* @param string $filter
* @param string $orderBy
* @param string $order
* @return \Zend\Db\ResultSet\ResultSet|\Zend\Paginator\Paginator
* @throws \Exception
*/
public function fetchAll($paginated = false, $filter = '', $orderBy = 'proposalDate', $order = 'ASC')
{
$view = 'vw_cr_proposal';
if ($paginated) {
return $this->paginate($filter, $orderBy, $order, $view);
}
$proposalView = new TableGateway($view, $this->adapter);
return $proposalView->select(array('proposalBy' => $this->staffId));
}
示例7: fetchAll
/**
* @param bool $paginated
* @param string $filter
* @param string $orderBy
* @param string $order
* @return \Zend\Db\ResultSet\ResultSet|\Zend\Paginator\Paginator
* @throws \Exception
*/
public function fetchAll($paginated = false, $filter = '', $orderBy = 'contactName', $order = 'ASC')
{
$view = 'vw_cr_contact';
if ($paginated) {
return $this->paginate($filter, $orderBy, $order, $view);
}
$contactView = new TableGateway($view, $this->adapter);
return $contactView->select();
}
示例8: __construct
/**
* Constructs instance.
*
* @param TableGateway $tableGateway
* @param Where|\Closure|string|array $where
* @param null $order
*/
public function __construct(TableGateway $tableGateway, $where = null, $order = null)
{
$select = $tableGateway->getSql()->select();
if ($where) {
$select->where($where);
}
if ($order) {
$select->order($order);
}
$dbAdapter = $tableGateway->getAdapter();
$resultSetPrototype = $tableGateway->getResultSetPrototype();
parent::__construct($select, $dbAdapter, $resultSetPrototype);
}
示例9: testGetRolesWithInheritance
/**
* @covers \BjyAuthorize\Provider\Role\ZendDb::getRoles
*/
public function testGetRolesWithInheritance()
{
$this->tableGateway->expects($this->any())->method('selectWith')->will($this->returnValue(array(array('id' => 1, 'role_id' => 'guest', 'is_default' => 1, 'parent_id' => null), array('id' => 2, 'role_id' => 'user', 'is_default' => 0, 'parent_id' => 1))));
$this->serviceLocator->expects($this->any())->method('get')->will($this->returnValue($this->tableGateway));
$provider = new ZendDb(array(), $this->serviceLocator);
$this->assertEquals($provider->getRoles(), array(new Role('guest'), new Role('user', 'guest')));
}
示例10: 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();
}
示例11: deleteCategory
public function deleteCategory($id)
{
try {
return $this->tableGateway->delete(array('id_category' => $id));
} catch (InvalidQueryException $e) {
return 0;
}
}
示例12: _initObject
/**
* This method init $this->object
*/
protected function _initObject($data = null)
{
if (is_null($data)) {
$data = $this->_itemsArrayDelault;
}
$this->_prepareTable($data);
$this->dbTable->insert($data);
}
示例13: testSave
public function testSave()
{
//Insert
$data = new ArrayObject(['fullName' => 'Test', 'email' => 'test@test.com']);
$this->assertEquals(1, $this->table->save($data));
$this->assertNotNull($data['id']);
//Update
$data = new ArrayObject(['id' => 1, 'fullName' => 'TestUser' . rand(10, 99), 'email' => 'test@test.com']);
$this->assertEquals(1, $this->table->save($data));
}
示例14: getCurrentVersion
public function getCurrentVersion($mdir_md5)
{
$select = new Select($this->tableGateway->getTable());
$select->where(array('mdir_md5' => $mdir_md5))->order('version DESC')->limit(1);
$result = $this->tableGateway->selectWith($select);
if (!$result->count()) {
return 0;
}
return $result->current()->getVersion();
}
示例15: 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();
}