作者:JohannesGirar
项目:WebCashRegister-zf
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);
}
作者:gotcm
项目:gotcm
/**
* 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);
}
}
作者:khinmyatky
项目:Office_Managemen
/**
* @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();
}
作者:khinmyatky
项目:Office_Managemen
/**
* @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));
}
作者:khinmyatky
项目:Office_Managemen
/**
* @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();
}
作者:khinmyatky
项目:Office_Managemen
/**
* @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));
}
作者:khinmyatky
项目:Office_Managemen
/**
* @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();
}
作者:idwsdt
项目:INIT-fram
/**
* 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);
}
作者:khinmyatky
项目:Office_Managemen
/**
* @param bool $paginated
* @param string $filter
* @param string $orderBy
* @param string $order
* @return \Zend\Db\ResultSet\ResultSet|Paginator
*/
public function fetchAll($paginated = false, $filter = '', $orderBy = 'voucherNo', $order = 'ASC')
{
$view = 'vw_account_receivable';
if ($paginated) {
$select = new Select($view);
$select->order($orderBy . ' ' . $order);
$where = new Where();
$where->literal("concat_ws(' ',description, voucherNo, Type, amount, voucherDate, currencyCode) LIKE ?", '%' . $filter . '%')->and->equalTo('depositBy', $this->staffId);
$select->where($where);
return $this->paginateWith($select);
}
$tableGateway = new TableGateway($view, $this->adapter);
return $tableGateway->select(array('depositBy' => $this->staffId));
}
作者:maiquelleone
项目:balanc
/**
* {@inheritdoc}
*/
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
// Captura de Configuração
$config = $serviceLocator->get('Config')['balance_manager']['factories'][$requestedName];
// Inicialização
$table = new Db\TableGateway\TableGateway($config['params']['table'], $serviceLocator->get('db'));
// Chave Primária e Sequência?
if (isset($config['params']['primary_key']) && isset($config['params']['sequence'])) {
// Configurar Sequência de Chave Primária
$table->getFeatureSet()->addFeature(new Db\TableGateway\Feature\SequenceFeature($config['params']['primary_key'], $config['params']['sequence']));
}
// Apresentação
return $table;
}
作者:solod
项目:xmai
public function getDocument($id)
{
$documentTable = new TableGateway('document', $this->adapter);
$rs = $documentTable->select(array('id' => intval($id)));
if ($rs->count()) {
$row = $rs->current();
$ObjectPropertyHydrator = new ObjectPropertyHydrator();
$document = new Document();
$ObjectPropertyHydrator->hydrate($row->getArrayCopy(), $document);
return $document;
} else {
throw new \Exception('data not exsist!');
}
}
作者:avz-cm
项目:zaboy-res
protected function _initObject($data = null)
{
if (is_null($data)) {
$data = $this->_itemsArrayDelault;
}
$this->_prepareTable($data, $this->cacheableDbTableName);
$this->_prepareTable($data, $this->dataSourceDbTableName);
$cacheableDbTable = new TableGateway($this->cacheableDbTableName, $this->adapter);
$dataSourceDbTable = new TableGateway($this->dataSourceDbTableName, $this->adapter);
foreach ($data as $record) {
$cacheableDbTable->insert($record);
$dataSourceDbTable->insert($record);
}
}
作者:solod
项目:xmai
public function saveAddress(Address $address)
{
if ($this->checkAddress($address->address)) {
// Save now.
$addressTable = new TableGateway('address', $this->adapter);
$hydrator = new ObjectPropertyHydrator();
$data = $hydrator->extract($address);
$addressTable->insert($data);
$id = $addressTable->lastInsertValue;
return $id;
} else {
throw new AddressAlreadyExsistException('Address already exsist!');
}
}
作者:sporkcod
项目:spor
/**
* Assert that a table has specified number for rows
*
* @param integer $count
* @param string|TableGateway $table
* @param string|array|Closure|PredicateInterface $where
* @throws \Exception on $table not a table name or TableGateway instance
*/
protected function assertTableRowCount($count, $table, $where = null)
{
if (is_string($table)) {
$table = new TableGateway\TableGateway($table, $this->getServices()->get('db'));
}
if (!$table instanceof TableGateway\TableGatewayInterface) {
throw new \Exception("{$table} must be a table name or TableGateway object");
}
$select = $table->getSql()->select()->columns(array('count' => new Expression('count(*)')));
if (null !== $where) {
$select->where($where);
}
$actual = $table->selectWith($select)->current()->count;
parent::assertEquals($count, $actual);
}
作者:michaelgumto
项目:bad-pupp
public function cityAction()
{
$adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
$id = $this->params()->fromRoute('id');
$cityTableGateway = new TableGateway('City', $adapter);
$city = $cityTableGateway->select(['ID' => $id])->toArray();
$tableGateway = new TableGateway('Country', $adapter);
if (count($city) < 0) {
throw new \Exception('No City found with ID ' . $id);
}
$city = $city[0];
$country = $tableGateway->select(['Code' => $city['CountryCode']])->toArray();
$country = $country[0];
return new ViewModel(['city' => $city, 'country' => $country]);
}
作者:JohannesGirar
项目:WebCashRegister-zf
public function saveCommande(Commande $Commande)
{
$data = array('COMMANDE_ID' => $Commande->commande_id, 'CLIENT_ID' => $Commande->client_id, 'COMMANDE_TABLE' => $Commande->commande_table, 'COMMANDE_STATUS' => $Commande->commande_status);
if (isset($Commande->commande_id)) {
$adapter = $this->tableGateway->getAdapter();
$otherTable = new TableGateway('commande', $adapter);
$otherTable->insert($data);
} else {
if ($this->getCommande($Commande->commande_id)) {
$this->tableGateway->update($data, array('COMMANDE_ID' => $Commande->commande_id, 'COMMANDE_STATUS' => $Commande->commande_status));
} else {
throw new \Exception('Form id does not exist');
}
}
}
作者:pbriliu
项目:BjyAuthoriz
/**
* @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')));
}
作者:Gee
项目:bad-pupp
/**
* @param $id
* @return City|null
*/
public function getCityById($id)
{
$city = $this->cityTable->select(['ID' => $id]);
if ($city->count() < 1) {
return null;
}
return $city->current();
}
作者:Lebe1g
项目:JobeetForZF
public function deleteCategory($id)
{
try {
return $this->tableGateway->delete(array('id_category' => $id));
} catch (InvalidQueryException $e) {
return 0;
}
}
作者:avz-cm
项目:zaboy-res
/**
* This method init $this->object
*/
protected function _initObject($data = null)
{
if (is_null($data)) {
$data = $this->_itemsArrayDelault;
}
$this->_prepareTable($data);
$this->dbTable->insert($data);
}