delete() public method

Deletes existing rows.
public delete ( array | string $where ) : integer
$where array | string SQL WHERE clause(s).
return integer The number of rows deleted.
示例#1
0
 /**
  * delete row(s)         
  * 
  * @param  array $data 
  * @return int
  */
 public function delete($id)
 {
     //delete permission of the resource
     $permissions = new Controlmodule_Model_DbTable_Permissions();
     $permissions->delete("resource_id=" . (int) $id);
     return parent::delete('id = ' . (int) $id);
 }
示例#2
0
 public function delete($id)
 {
     try {
         parent::delete($id);
     } catch (Exception $e) {
         echo 'Ocorreu um erro ao excluir os dados.';
     }
 }
示例#3
0
 public function delete($id)
 {
     try {
         parent::delete($id);
     } catch (Exception $e) {
         echo 'Opa... algum problema aconteceu.';
     }
 }
示例#4
0
 public function delete($where)
 {
     $this->where = $where;
     $last_id = parent::delete($this->where);
     if ($last_id > 0) {
         $this->_notifyObservers("delete");
     }
     return $last_id;
 }
示例#5
0
 public function delete($id)
 {
     try {
         parent::delete($id);
     } catch (Exception $exc) {
         //echo $exc->getTraceAsString();
         echo 'Ocorreu um erro ao excluir os dados';
     }
 }
示例#6
0
文件: Table.php 项目: eryx/labs
 public function delete($where)
 {
     if (count($where) == 0) {
         throw new Exception();
     }
     foreach ($where as $k => $v) {
         $where[$k . ' = ?'] = $v;
         unset($where[$k]);
     }
     return parent::delete($where);
 }
示例#7
0
 /**
  * Bulk Delete entries
  *
  * @param  array With serialized ids
  * @return bool
  */
 protected function bulkDelete(array $bulkIds)
 {
     if (empty($bulkIds)) {
         return false;
     }
     foreach ($bulkIds as $id) {
         $primaryKey = urldecode($id);
         $where = $this->_getWhereStatement($primaryKey);
         $this->obj->delete($where);
     }
     return true;
 }
 /**
  * deleteNode
  * @param integer $intNodeId
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0 
  */
 public function deleteNode($intNodeId)
 {
     $this->intNodeId = $intNodeId;
     $this->loadNodeData();
     if ($this->objNodeData instanceof Zend_Db_Table_Rowset_Abstract && count($this->objNodeData) > 0) {
         $arrNode = $this->objNodeData->current()->toArray();
         if (!is_null($this->strDBFRoot)) {
             $this->intRootId = $arrNode[$this->strDBFRoot];
         }
         $this->lockTable();
         $strSqlAddonRootId = '';
         if (!is_null($this->strDBFRoot) && $this->intRootId > 0) {
             $strSqlAddonRootId = $this->strDBFRoot . ' = ' . $this->intRootId . ' AND ';
         }
         /**
          * delete categories
          */
         $this->objTable->delete($strSqlAddonRootId . $this->strDBFLft . ' BETWEEN ' . $arrNode[$this->strDBFLft] . ' AND ' . $arrNode[$this->strDBFRgt] . '');
         $this->shiftLRValues($arrNode[$this->strDBFRgt] + 1, $arrNode[$this->strDBFLft] - $arrNode[$this->strDBFRgt] - 1);
         $this->unlockTable();
     }
 }
示例#9
0
 public function delete($where)
 {
     parent::delete($where);
     //    $this->_purgeCache();
 }
示例#10
0
 /**
  * Deletes existing rows.
  *
  * @param  array|string $where SQL WHERE clause(s).
  * @return int          The number of rows deleted.
  */
 public function delete($where)
 {
     Centurion_Signal::factory('pre_delete')->send($this, array($where));
     list($found, $return) = Centurion_Traits_Common::checkTraitOverload($this, 'delete', array($where));
     if (!$found) {
         $return = parent::delete($where);
     }
     Centurion_Signal::factory('post_delete')->send($this, array($where));
     return $return;
 }
示例#11
0
 /**
  * Delete from the database.
  *
  * @param MIDAS_GlobalDao $dao
  * @return true
  * @throws Zend_Exception
  */
 public function delete($dao)
 {
     if (!$dao->saved) {
         throw new Zend_Exception('The dao should be saved first ...');
     }
     if (!isset($this->_key) || !$this->_key) {
         $query = array();
         foreach ($this->_mainData as $name => $option) {
             if ($option['type'] == MIDAS_DATA) {
                 $query[$name . ' = ?'] = $dao->{$name};
             }
         }
         if (empty($query)) {
             throw new Zend_Exception('Huge error, you almost deleted everything');
         }
         parent::delete($query);
         $dao->saved = false;
         return true;
     }
     $key = $dao->getKey();
     if (!isset($key)) {
         throw new Zend_Exception('Unable to find the key');
     }
     parent::delete(array($this->_key . ' = ?' => $dao->getKey()));
     $key = $dao->_key;
     $dao->set($key, null);
     $dao->saved = false;
     return true;
 }
示例#12
0
 /**
  * Deletes existing rows.
  *
  * @param  array|string $where SQL WHERE clause(s).
  * @return int          The number of rows deleted.
  */
 public function delete($where)
 {
     $this->_setAdapter(Zoo::getService('db')->getDb('master'));
     return parent::delete($where);
 }
示例#13
0
 /**
  * Deletes existing rows.
  * @param  array|string $where SQL WHERE clause(s).
  * @return int          The number of rows deleted.
  */
 public function delete($where)
 {
     $this->notifyObservers('beforeDelete', array($this, &$where));
     $result = parent::delete($where);
     $this->notifyObservers('afterDelete', array($this, $result, $where));
     return $result;
 }
示例#14
0
 /**
  * Delete all rules that are for a specific action
  *
  * @param int $actionId
  * @return int number of deleted rows
  */
 public function deleteByActionId($actionId)
 {
     return parent::delete($this->getAdapter()->quoteInto('uaru_uaa_id = ?', $actionId, Zend_Db::INT_TYPE));
 }
 public function delete($where)
 {
     if ($this->_cache) {
         $this->_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG);
     }
     return parent::delete($where);
 }
示例#16
0
 /**
  * Delete the record by its id
  * 
  * @param int $id 
  */
 public function delete($id)
 {
     try {
         if ($this->useTransaction()) {
             $this->getAdapter()->beginTransaction();
         }
         $tmp = $this->get($id);
         //$objid = $tmp->objid;
         $where = $this->getAdapter()->quoteInto($this->_primary . ' = ?', $id);
         $r = parent::delete($where);
         //            $do = new Agana_Domain_Object();
         //            $o = $do->getById($objid);
         //            $do->setObject($o);
         //            $do->delete();
         if ($this->useTransaction()) {
             $this->getAdapter()->commit();
         }
         return;
     } catch (Exception $pdoe) {
         if ($this->useTransaction()) {
             $this->getAdapter()->rollBack();
         }
         throw new Agana_Exception($pdoe->getMessage());
     }
 }
示例#17
0
 /**
  * Helper function to delete data from a table.
  *
  * @param \Zend_Db_Table_Abstract $table The table to delete from.
  * @param array $filter The filter for deleting. This is required to prevent deleting all data in a table.
  * @param array $deleteUpdates Does not do a real delete, but updates the database instead.
  * @return int The number of rows deleted / updated
  */
 protected function _deleteTableData(\Zend_Db_Table_Abstract $table, array $filter, array $deleteUpdates = null)
 {
     if ($filter) {
         $adapter = $this->getAdapter();
         $wheres = array();
         foreach ($filter as $name => $value) {
             if (is_int($name)) {
                 $wheres[] = $value;
             } else {
                 $wheres[$adapter->quoteIdentifier($name) . ' = ?'] = $value;
             }
         }
         if ($deleteUpdates) {
             return $table->update($deleteUpdates, $wheres);
         } else {
             return $table->delete($wheres);
         }
     }
     return 0;
 }
示例#18
0
文件: Model.php 项目: omusico/logica
 /**
  * Overrides delete() from Zend_Db_Table_Abstract
  * 
  * @param mixed $where 
  * @access public
  * @return int
  */
 public function delete($where)
 {
     $where = $this->_normalizeWhere($where);
     return parent::delete($where);
 }
示例#19
0
 /**
  * Delete all launchers of $type for a specific user
  *
  * @param int $userId
  * @param int $type  (see constants defined in Webdesktop_Model_DbTable_Launchers)
  * @return int number of affected rows
  */
 public function deleteByUserType($userId, $type)
 {
     return parent::delete(array($this->getAdapter()->quoteInto('l_u_id = ?', $userId, Zend_Db::INT_TYPE), $this->getAdapter()->quoteInto('l_type = ?', $type)));
 }
示例#20
0
 /** Delete the data
  * @@access public
  * @param array $where
  * @return \Pas_Db_Table_Caching
  */
 public function delete($where)
 {
     parent::delete($where);
     $this->_purgeCache();
     return $this;
 }
示例#21
0
 /**
  * Deletes existing rows.
  *
  * @param  array|string $where SQL WHERE clause(s).
  * @return int          The number of rows deleted.
  */
 public function delete($where)
 {
     Centurion_Signal::factory('pre_delete')->send($this, array($where));
     $return = parent::delete($where);
     Centurion_Signal::factory('post_delete')->send($this, array($where));
     return $return;
 }
示例#22
0
 /**
  * Delete all inheritances for a specific role
  *
  * If a role is deleted use this method to delete all roles that extend
  * the deleted role
  *
  * @param int $roleId
  * @return int number of deleted rows
  */
 public function deleteWithRoleId($roleId)
 {
     return parent::delete($this->getAdapter()->quoteInto('uari_uar_id = ?', $roleId, Zend_Db::INT_TYPE));
 }
 /**
  * Override to use is_deleted field
  */
 public function delete($where = false, $force = false)
 {
     $info = $this->info();
     if ($force or array_search('is_deleted', $info['cols']) == false) {
         return parent::delete($where);
     } else {
         $data = array();
         $data['is_deleted'] = 1;
         parent::update($data, $where);
     }
 }
 /**
  * Delete records from DB table
  * 
  * @param	int|string	$where	Id of record to delete, or WHERE statement.
  * @return	int			Number of rows deleted.
  */
 public function delete($where)
 {
     if (is_numeric($where)) {
         $where = $this->getPrimaryWhere($where);
     }
     return parent::delete($where);
 }
 /**
  * Delete rows from database
  *
  * @param mixed $condition
  * @return int Returns the number of rows deleted 
  */
 public function delete($condition = NULL)
 {
     $rows = 0;
     $this->_preDelete($condition);
     if (NULL !== $condition) {
         $rows = parent::delete($condition);
     } else {
         if ($this->getId()) {
             $where = $this->getAdapter()->quoteInto($this->getAdapter()->quoteIdentifier($this->primary) . '=?', $this->getId());
             $rows = parent::delete($where);
         }
     }
     $this->_postDelete($condition, $rows);
     return $rows;
 }
示例#26
0
 /**
  * Delete a record and all his relations.
  *
  * @return Phprojekt_ActiveRecord_Abstract An instance of Phprojekt_ActiveRecord_Abstract.
  */
 public function delete()
 {
     if (array_key_exists('id', $this->_data)) {
         if (array_key_exists('hasMany', $this->_relations) || count($this->hasMany) > 0) {
             foreach (array_keys($this->hasMany) as $key) {
                 $className = $this->_getClassNameForRelationship($key, $this->hasMany);
                 $im = new $className($this->getAdapter());
                 $tableName = $im->getTableName();
                 $columnName = $this->_translateKeyFormat(get_class($this));
                 $this->getAdapter()->delete($tableName, sprintf('%s = %d', $this->getAdapter()->quoteIdentifier($columnName), (int) $this->id));
             }
         }
         if (array_key_exists('hasManyAndBelongsToMany', $this->_relations) || count($this->hasManyAndBelongsToMany) > 0) {
             // We just delete the data from the relations and do
             // not do an lookup for a cascade delete if there is no
             // relation anymore
             foreach (array_keys($this->hasManyAndBelongsToMany) as $key) {
                 $className = $this->_getClassNameForRelationship($key, $this->hasManyAndBelongsToMany);
                 $keyName = $this->_translateKeyFormat(get_class($this));
                 $im = new $className($this->getAdapter());
                 $tableName = $this->_translateIntoRelationTableName($this, $im);
                 $this->getAdapter()->delete($tableName, sprintf('%s = %d', $this->getAdapter()->quoteIdentifier($keyName), (int) $this->id));
             }
         }
         parent::delete(sprintf('id = %d', (int) $this->_data['id']));
         $this->_initDataArray();
         $this->_relations = array();
     }
     return $this;
 }
示例#27
0
 public function delete($_id)
 {
     $this->dbTable->delete(array('id = ?' => $_id));
 }
示例#28
0
 /**
  * (non-PHPdoc)
  * @see Zend_Db_Table_Abstract::delete()
  */
 public function delete($where)
 {
     $return = parent::delete($where);
     App_Cache::remove($this->getTableName());
     return $return;
 }
 public function delete($where)
 {
     return parent::delete($where);
 }
示例#30
0
 /**
  * @todo remove this, need use Axis::message in controllers
  *
  * @param  array|string $where SQL WHERE clause(s).
  * @return int          The number of rows deleted.
  */
 public function delete($where)
 {
     try {
         return parent::delete($where);
     } catch (Exception $e) {
         Axis::message()->addError($e->getMessage());
         return false;
     }
 }