本文整理汇总了PHP中Zend\Db\Sql\Sql::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Sql::delete方法的具体用法?PHP Sql::delete怎么用?PHP Sql::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\Sql\Sql
的用法示例。
在下文中一共展示了Sql::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDelete
/**
* @covers Zend\Db\Sql\Sql::delete
*/
public function testDelete()
{
$delete = $this->sql->delete();
$this->assertInstanceOf('Zend\\Db\\Sql\\Delete', $delete);
$this->assertSame('foo', $delete->getRawState('table'));
$this->setExpectedException('Zend\\Db\\Sql\\Exception\\InvalidArgumentException', 'This Sql object is intended to work with only the table "foo" provided at construction time.');
$this->sql->delete('bar');
}
示例2: archive
/**
* @return $successfulArchive
*/
public function archive() : bool
{
if ($this->isArchivedTable()) {
// @todo: Replace pseudo code
$archived = !$this->sql->create($this->getArchivedTablename());
if ($archived) {
$archived = $archived && $this->delete();
if ($archived) {
$duplicate = false;
} else {
$duplicate = !$this->sql->delete($this->getArchivedTablename());
}
}
} else {
$archived = false;
}
if ($success) {
$this->record('arc_suc', RecordService::INFO, 'Archived entity successfully.', $this->data);
} elseif ($duplicate) {
$this->record('arc_err', RecordService::ERROR, 'Archiving ended up with duplicate data sets. ', $this->data);
} else {
$this->record('arc_fai', RecordService::ERROR, 'Archiving failed.', $this->data);
}
return (bool) $success;
}
示例3: deleteBy
/**
* Delete a record by predicate
*
* @param Where|\Closure|string|array|Predicate\PredicateInterface $predicate
* @param string $combination One of the OP_* constants from Predicate\PredicateSet
*
* @return integer the number of affected rows (can be be influenced by triggers or cascade)
*/
public function deleteBy($predicate, $combination = Predicate\PredicateSet::OP_AND)
{
$delete = $this->sql->delete($this->prefixed_table)->where($predicate, $combination);
$statement = $this->sql->prepareStatementForSqlObject($delete);
$result = $statement->execute();
return $result->getAffectedRows();
}
示例4: indexAction
public function indexAction()
{
date_default_timezone_set('Asia/Dubai');
$auth = new AuthenticationService();
$container = new Container('username');
$sm = $this->getServiceLocator();
$dba = $sm->get($container->adapter);
$secsql = "SELECT * FROM section";
$secstatement = $dba->query($secsql, array(5));
$section = new ResultSet();
$section->initialize($secstatement);
$teasql = "SELECT * FROM teacher";
$teastatement = $dba->query($teasql, array(5));
$teacher = new ResultSet();
$teacher->initialize($teastatement);
if ($auth->hasIdentity() && $container->type == 0) {
if ($this->getRequest()->getPost('submit-update')) {
$count = (int) $this->getRequest()->getPost('rcount');
for ($i = 1; $i <= $count; $i++) {
$id = $this->getRequest()->getPost('rid' . $i);
$att = $this->getRequest()->getPost('rattendance' . $i);
$com = $this->getRequest()->getPost('rcomment' . $i);
$stup = $this->getRequest()->getPost('status-update' . $i);
if ($stup != 0) {
$data = array('counted' => $att, 'comment' => $com, 'Abs_value' => $stup);
$sql = new Sql($dba);
$update = $sql->update();
$update->table('attendance');
$update->set($data);
$update->where(array('Att_id' => $id));
$statement = $sql->prepareStatementForSqlObject($update);
$statement->execute();
} else {
$id = $this->getRequest()->getPost('rid' . $i);
$sql = new Sql($dba);
$delete = $sql->delete('attendance')->where(array('Att_id' => $id));
$statement = $sql->prepareStatementForSqlObject($delete);
$statement->execute();
}
}
$sday = $this->getRequest()->getPost('sdate-filter');
$eday = $this->getRequest()->getPost('edate-filter');
$syour_date = date("Y-m-d", strtotime($sday));
$eyour_date = date("Y-m-d", strtotime($eday));
return new ViewModel(array('attendance' => $this->getRepport($syour_date, $eyour_date, $this->getRequest()->getPost('stid-filter'), $this->getRequest()->getPost('tea-filter'), $this->getRequest()->getPost('sec-filter'), $this->getRequest()->getPost('p-filter'), $this->getRequest()->getPost('status-filter')), 'sections' => $section, 'teachers' => $teacher, 'message' => "Attendance report updated", 'sday' => $sday, 'eday' => $eday, 'stid' => $this->getRequest()->getPost('stid-filter'), 'tid' => $this->getRequest()->getPost('tea-filter'), 'secid' => $this->getRequest()->getPost('sec-filter'), 'pid' => $this->getRequest()->getPost('p-filter'), 'status' => $this->getRequest()->getPost('status-filter'), 'filter' => "Attendance report for " . $this->getRequest()->getPost('stid-filter') . " from " . date("l jS \\of F Y ", strtotime($sday)) . " to " . date("l jS \\of F Y ", strtotime($eday))));
} else {
if ($this->getRequest()->getPost('submit-date')) {
$sday = $this->getRequest()->getPost('sdate-filter');
$eday = $this->getRequest()->getPost('edate-filter');
$syour_date = date("Y-m-d", strtotime($sday));
$eyour_date = date("Y-m-d", strtotime($eday));
return new ViewModel(array('attendance' => $this->getRepport($syour_date, $eyour_date, $this->getRequest()->getPost('stid-filter'), $this->getRequest()->getPost('tea-filter'), $this->getRequest()->getPost('sec-filter'), $this->getRequest()->getPost('p-filter'), $this->getRequest()->getPost('status-filter')), 'sections' => $section, 'teachers' => $teacher, 'message' => "", 'sday' => $sday, 'eday' => $eday, 'stid' => $this->getRequest()->getPost('stid-filter'), 'tid' => $this->getRequest()->getPost('tea-filter'), 'secid' => $this->getRequest()->getPost('sec-filter'), 'pid' => $this->getRequest()->getPost('p-filter'), 'status' => $this->getRequest()->getPost('status-filter'), 'filter' => "Attendance report for " . $this->getRequest()->getPost('stid-filter') . " from " . date("l jS \\of F Y ", strtotime($sday)) . " to " . date("l jS \\of F Y ", strtotime($eday))));
} else {
return new ViewModel(array('attendance' => $this->getRepport(date('Y-m-d'), date('Y-m-d'), "", 0, 0, 0, 0), 'sections' => $section, 'teachers' => $teacher, 'message' => "", 'sday' => date('m/d/Y'), 'eday' => date('m/d/Y'), 'stid' => "", 'tid' => 0, 'secid' => 0, 'pid' => 0, 'status' => 0, 'filter' => "Attendance report for " . date("l jS \\of F Y ", strtotime(date('m/d/Y')))));
}
}
} else {
return $this->redirect()->toRoute('login', array('controller' => 'index', 'action' => 'login'));
}
}
示例5: delete
/**
* Removes this record from the database
*/
protected function delete()
{
if ($this->getId()) {
$sql = new Sql(Database::getConnection(), $this->tablename);
$delete = $sql->delete()->where(['id' => $this->getId()]);
$sql->prepareStatementForSqlObject($delete)->execute();
}
}
示例6: cleanPriorForgotRequests
public function cleanPriorForgotRequests($userId)
{
$sql = new Sql($this->getDbAdapter(), $this->tableName);
$delete = $sql->delete();
$delete->where->equalTo($this->userField, $userId);
$statement = $sql->prepareStatementForSqlObject($delete);
$statement->execute();
return true;
}
示例7: delete
/**
* Delete
*
* @param Entity $entity Entity
*
* @return void
*/
public function delete(Entity $entity)
{
$delete = $this->_sql->delete();
$delete->from($entity->getTableName());
if ($entity->getPrimaryKey() && $entity->getId()) {
$delete->where([$entity->getPrimaryKey() => $entity->getId()]);
}
$this->_executeSql($this->_sql, $delete);
}
示例8: delete
public function delete($where)
{
$delete = $this->sql->delete($this->_table);
$delete->where($where);
$result = $this->_execute($delete);
if ($result) {
return true;
}
return false;
}
示例9: delete
/**
* Deletes a record.
* @param $id
* @throws Exception if no records are deleted
* @return $this
*/
public function delete($id)
{
$adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
$sql = new Sql($adapter);
$delete = $sql->delete('room')->where(array('id' => $id));
$res = $sql->prepareStatementForSqlObject($delete)->execute();
if ($res->getAffectedRows() < 1) {
throw new \Exeption('Room not deleted: DB affected rows count=0.');
}
}
示例10: deleteById
public function deleteById($cartItemId)
{
$sql = new Sql($this->getDbAdapter(), $this->tableName);
$where = new Where();
$where->equalTo($this->itemIdField, $cartItemId);
$delete = $sql->delete();
$delete->where($where);
$statement = $sql->prepareStatementForSqlObject($delete);
$result = $statement->execute();
return $result->getAffectedRows();
}
示例11: delete
/**
* Delete
*
* @param Closure $where
* @return int
*/
public function delete($where)
{
$delete = $this->sql->delete();
if ($where instanceof \Closure) {
$where($delete);
} else {
$delete->where($where);
}
$statement = $this->sql->prepareStatementForSqlObject($delete);
$result = $statement->execute();
return $result->getAffectedRows();
}
示例12: cancelMatch
/**
* Delete current Match for cancelation
* @param Integer $id
* @return array
*/
public function cancelMatch($id)
{
$sql = new Sql($this->dbAdapter);
$delete = $sql->delete('tblmatch');
$delete->where(array('matchID = ?' => $id));
$stmt = $sql->prepareStatementForSqlObject($delete);
$result = $stmt->execute();
if ($result instanceof ResultInterface) {
return array('canceled' => true);
}
return array('canceled' => false);
}
示例13: delete
/**
* Delete
*
* @param Where|\Closure|string|array $where
* @return int
*/
public function delete($where)
{
if (!$this->isInitialized) {
$this->initialize();
}
$delete = $this->sql->delete();
if ($where instanceof \Closure) {
$where($delete);
} else {
$delete->where($where);
}
return $this->executeDelete($delete);
}
示例14: expireAction
public function expireAction()
{
$verbose = $this->params()->fromRoute('verbose');
$db = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
$sql = new Sql($db);
$delete = $sql->delete();
$delete->from('sessions')->where('expires < NOW()');
$statement = $sql->prepareStatementForSqlObject($delete);
$result = $statement->execute();
if ($result && $verbose) {
echo "Deleted " . number_format($result->count()) . " session(s)\n";
}
exit;
}
示例15: delete
public function delete($id)
{
$adapter = $this->adapter;
$sql = new Sql($this->adapter);
$delete = $sql->delete('user_address');
$delete->from('user_address');
$delete->where(array('addr_id' => $id));
$statement = $sql->prepareStatementForSqlObject($delete);
try {
$affectedRows = $statement->execute()->getAffectedRows();
} catch (\Exception $e) {
die('Error: ' . $e->getMessage());
}
return true;
}