本文整理汇总了PHP中Zend\Db\TableGateway\TableGateway::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP TableGateway::delete方法的具体用法?PHP TableGateway::delete怎么用?PHP TableGateway::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\TableGateway\TableGateway
的用法示例。
在下文中一共展示了TableGateway::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteCategory
public function deleteCategory($id)
{
try {
return $this->tableGateway->delete(array('id_category' => $id));
} catch (InvalidQueryException $e) {
return 0;
}
}
示例2: delete
/**
* Delete a resource
*
* @param mixed $id
* @return ApiProblem|mixed
*/
public function delete($id)
{
$result = $this->fetch($id);
if (!$result) {
return new ApiProblem(404, 'Registro não encontrado');
}
$this->tableGateway->delete(array('id' => $id));
return true;
}
示例3: 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);
}
}
示例4: deleteanywhere
public function deleteanywhere($mytable, $where)
{
$db = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
$table = new TableGateway($mytable, $db);
$table->delete($where);
return 1;
}
示例5: testDelete
/**
* @covers Zend\Db\TableGateway\TableGateway::delete
*/
public function testDelete()
{
$mockDelete = $this->mockSql->delete();
// assert select::from() is called
$mockDelete->expects($this->once())->method('where')->with($this->equalTo('foo'));
$this->table->delete('foo');
}
示例6: delete
/**
* Удаляет объект
*
* @param mixed $id
* @return \App\Storage\Mysql\Simple
*/
public function delete($id)
{
if ($id instanceof EntityInterface) {
$id = $id->getKeyValue();
}
$this->tableGateway->delete(array($this->getItemSetProto()->getFactory()->getEntityProto()->getKeyName() => $id));
return $this;
}
示例7: testDelete
/**
* @covers Zend\Db\TableGateway\TableGateway::delete
*/
public function testDelete()
{
$delete = $this->getMock('Zend\\Db\\Sql\\Delete');
// assert select::from() is called
$delete->expects($this->once())->method('where')->with($this->equalTo('foo'));
$this->table->setSqlDelete($delete);
$this->table->delete('foo');
}
示例8: clearLock
/**
* @param Lock\Handle $handle
*/
public function clearLock(Lock\Handle $handle)
{
if (!isset($this->locks[$handle->getToken()])) {
return;
}
$key = $this->locks[$handle->getToken()];
$this->gateway->delete(['key' => $key]);
unset($this->locks[$handle->getToken()]);
}
示例9: remove
/**
* @param Request $request
* @param Response $response
* @param $args
*
* @return ResponseInterface
*/
public function remove(Request $request, Response $response, $args)
{
try {
$result = $this->gateway->delete($this->getIdArray($args));
return $response->withJson(["result" => $result]);
} catch (\Exception $e) {
return $response->withStatus(400);
}
}
示例10: deleteAccount
/**
* Deletes the account with the given id
* @param int|string $id
*/
public function deleteAccount($id)
{
$account = $this->getAccount($id);
$dir = getcwd() . '/public/users/' . $account->getName();
if (file_exists($dir)) {
$this->rrmdir($dir);
}
$this->tableGateway->delete(['id' => $id]);
}
示例11: delete
/**
* delete by id of the table or array condition
*
* @param int/array $id
*/
public function delete($id)
{
try {
if (is_array($id)) {
$effectedRows = $this->tableGateway->delete($id);
} else {
$effectedRows = $this->tableGateway->delete(array('id' => (int) $id));
}
} catch (\Exception $e) {
return \Model\Custom\Error::trigger($e, $params);
}
return $effectedRows;
}
示例12: deleteNode
/**
* Delete node
*
* @param integer $leftKey
* @param integer $rightKey
* @param array $filter
* @param boolean $useTransaction
* @return boolean|string
*/
public function deleteNode($leftKey, $rightKey, array $filter = [], $useTransaction = true)
{
try {
if ($useTransaction) {
$this->tableGateway->getAdapter()->getDriver()->getConnection()->beginTransaction();
}
$predicate = new Predicate();
$this->tableGateway->delete([$predicate->greaterThanOrEqualTo($this->left, $leftKey), $predicate->lessThanOrEqualTo($this->right, $rightKey)] + $filter);
$predicate = new Predicate();
$this->tableGateway->update([$this->left => new Expression('IF(' . $this->left . ' > ?, ' . $this->left . ' - (? - ? + 1), ' . $this->left . ')', [$leftKey, $rightKey, $leftKey]), $this->right => new Expression($this->right . ' - (? - ? + 1)', [$rightKey, $leftKey])], [$predicate->greaterThan($this->right, $rightKey)] + $filter);
if ($useTransaction) {
$this->tableGateway->getAdapter()->getDriver()->getConnection()->commit();
}
} catch (Exception $e) {
if ($useTransaction) {
$this->tableGateway->getAdapter()->getDriver()->getConnection()->rollback();
}
ApplicationErrorLogger::log($e);
return $e->getMessage();
}
return true;
}
示例13: deleteUser
/**
* @param int $id
*/
public function deleteUser($id)
{
$this->tableGateway->delete(array('user_id' => (int) $id));
}
示例14: delete
public function delete($version, $mdir_md5)
{
$this->tableGateway->delete(array('version' => $version, 'mdir_md5' => $mdir_md5));
}
示例15: deleteAll
/**
* {@inheritdoc}
*
* {@inheritdoc}
*/
public function deleteAll()
{
$where = '1=1';
$deletedItemsCount = $this->dbTable->delete($where);
return $deletedItemsCount;
}