當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sql::delete方法代碼示例

本文整理匯總了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');
 }
開發者ID:rajanlamic,項目名稱:IntTest,代碼行數:11,代碼來源:SqlTest.php

示例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;
 }
開發者ID:geolysis,項目名稱:gz3-base,代碼行數:28,代碼來源:AbstractManager.php

示例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();
 }
開發者ID:robocoder,項目名稱:solublecomponents,代碼行數:15,代碼來源:Table.php

示例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'));
     }
 }
開發者ID:krystouf,項目名稱:injazfuj,代碼行數:60,代碼來源:IndexController.php

示例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();
     }
 }
開發者ID:City-of-Bloomington,項目名稱:myCity,代碼行數:11,代碼來源:ActiveRecord.php

示例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;
 }
開發者ID:dnconcept,項目名稱:GoalioForgotPassword,代碼行數:9,代碼來源:Password.php

示例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);
 }
開發者ID:VaD1ke,項目名稱:redmine_telegram_notifier,代碼行數:16,代碼來源:Collection.php

示例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;
 }
開發者ID:biialaborg,項目名稱:budocu.com,代碼行數:10,代碼來源:AbstractRepository.php

示例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.');
     }
 }
開發者ID:rav990,項目名稱:AplikacjaRestPhp,代碼行數:16,代碼來源:Rooms.php

示例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();
 }
開發者ID:nclundsten,項目名稱:SpeckCart,代碼行數:11,代碼來源:CartItemMapperZendDb.php

示例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();
 }
開發者ID:rikaix,項目名稱:zf2,代碼行數:18,代碼來源:TableGateway.php

示例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);
 }
開發者ID:DieDreiTechGetiere,項目名稱:LNSU-backend,代碼行數:17,代碼來源:GameTable.php

示例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);
 }
開發者ID:artpoplsh,項目名稱:learningZf2,代碼行數:19,代碼來源:AbstractTableGateway.php

示例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;
 }
開發者ID:zealproject,項目名稱:zeal-session,代碼行數:14,代碼來源:CliController.php

示例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;
 }
開發者ID:ankuradhey,項目名稱:laundry,代碼行數:15,代碼來源:UsertrackMapper.php


注:本文中的Zend\Db\Sql\Sql::delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。