本文整理汇总了PHP中Zend_Db_Adapter_Abstract::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Abstract::delete方法的具体用法?PHP Zend_Db_Adapter_Abstract::delete怎么用?PHP Zend_Db_Adapter_Abstract::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Adapter_Abstract
的用法示例。
在下文中一共展示了Zend_Db_Adapter_Abstract::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteOther
public function deleteOther(ActiveSync_Model_SyncState $_syncState)
{
// remove all other synckeys
$where = array($this->_db->quoteInto('device_id = ?', $_syncState->device_id), $this->_db->quoteInto('type = ?', $_syncState->type), $this->_db->quoteInto('counter != ?', $_syncState->counter));
$this->_db->delete(SQL_TABLE_PREFIX . 'acsync_synckey', $where);
return true;
}
示例2: saveRel
public function saveRel(Mage_Admin_Model_Permissions_Rules $rule)
{
$this->_write->beginTransaction();
try {
$roleId = $rule->getRoleId();
$this->_write->delete($this->_ruleTable, "role_id = {$roleId}");
$masterResources = Mage::getModel('admin/permissions_roles')->getResourcesList2D();
$masterAdmin = false;
if ($postedResources = $rule->getResources()) {
foreach ($masterResources as $index => $resName) {
if (!$masterAdmin) {
$permission = in_array($resName, $postedResources) ? 'allow' : 'deny';
$this->_write->insert($this->_ruleTable, array('role_type' => 'G', 'resource_id' => trim($resName, '/'), 'privileges' => '', 'assert_id' => 0, 'role_id' => $roleId, 'permission' => $permission));
}
if ($resName == 'all' && $permission == 'allow') {
$masterAdmin = true;
}
}
}
$this->_write->commit();
} catch (Mage_Core_Exception $e) {
throw $e;
} catch (Exception $e) {
$this->_write->rollBack();
}
}
示例3: delete
public function delete(Mage_Admin_Model_Permissions_Roles $role)
{
$this->_write->beginTransaction();
try {
$this->_write->delete($this->_roleTable, "role_id={$role->getId()}");
$this->_write->delete($this->_roleTable, "parent_id={$role->getId()}");
$this->_write->delete($this->_ruleTable, "role_id={$role->getId()}");
$this->_write->commit();
} catch (Mage_Core_Exception $e) {
throw $e;
} catch (Exception $e) {
$this->_write->rollBack();
}
}
示例4: __unset
/**
* Remove um valor do registro
*
* @param string $key
*/
public function __unset($key)
{
if (isset($this->{$key})) {
$this->db->delete("registry", "context='{$this->getContext()}' AND `key`='{$key}'");
$this->update();
}
}
示例5: validate
/**
* get array of ids which got send to the client for a given class
*
* @param Syncope_Model_IDevice|string $_deviceId
* @param Syncope_Model_IFolder|string $_folderId
* @return Syncope_Model_SyncState
*/
public function validate($_deviceId, $_folderId, $_syncKey)
{
$deviceId = $_deviceId instanceof Syncope_Model_IDevice ? $_deviceId->id : $_deviceId;
$folderId = $_folderId instanceof Syncope_Model_IFolder ? $_folderId->id : $_folderId;
$select = $this->_db->select()->from($this->_tablePrefix . 'synckey')->where($this->_db->quoteIdentifier('device_id') . ' = ?', $deviceId)->where($this->_db->quoteIdentifier('counter') . ' = ?', $_syncKey)->where($this->_db->quoteIdentifier('type') . ' = ?', $folderId);
$stmt = $this->_db->query($select);
$state = $stmt->fetchObject('Syncope_Model_SyncState');
$stmt = null;
# see https://bugs.php.net/bug.php?id=44081
if (!$state instanceof Syncope_Model_ISyncState) {
return false;
}
$this->_convertFields($state);
// check if this was the latest syncKey
$select = $this->_db->select()->from($this->_tablePrefix . 'synckey')->where($this->_db->quoteIdentifier('device_id') . ' = ?', $deviceId)->where($this->_db->quoteIdentifier('counter') . ' = ?', $_syncKey + 1)->where($this->_db->quoteIdentifier('type') . ' = ?', $folderId);
$stmt = $this->_db->query($select);
$moreRecentState = $stmt->fetchObject('Syncope_Model_SyncState');
$stmt = null;
# see https://bugs.php.net/bug.php?id=44081
// found more recent synckey => the last sync repsone got not received by the client
if ($moreRecentState instanceof Syncope_Model_ISyncState) {
// undelete entries marked as deleted in syncope_content table
$this->_db->update($this->_tablePrefix . 'content', array('is_deleted' => 0), array('device_id = ?' => $deviceId, 'folder_id = ?' => $folderId, 'creation_synckey = ?' => $state->counter, 'is_deleted = ?' => 1));
// remove entries added during latest sync in syncope_content table
$this->_db->delete($this->_tablePrefix . 'content', array('device_id = ?' => $deviceId, 'folder_id = ?' => $folderId, 'creation_synckey > ?' => $state->counter));
} else {
// finaly delete all entries marked for removal in syncope_content table
$this->_db->delete($this->_tablePrefix . 'content', array('device_id = ?' => $deviceId, 'folder_id = ?' => $folderId, 'is_deleted = ?' => 1));
}
// remove all other synckeys
$this->_deleteOtherStates($state);
return $state;
}
示例6: delete
/**
* Proxy the call to delete
*
* @param string|object $table
* @param string $where
*/
public function delete($table, $where = '')
{
if (is_object($table)) {
$where = 'id = ' . $table->id;
if ($this->searchService != null) {
$this->searchService->delete($table);
}
if ($this->tagService != null) {
$this->tagService->deleteTags($table, za()->getUser());
}
if ($this->itemLinkService != null) {
$this->itemLinkService->deleteItem($table);
}
$table = get_class($table);
}
$table = strtolower($table);
$return = false;
try {
$this->beginTransaction();
if (is_array($where)) {
$where = $this->bindValues($where);
}
$this->proxied->delete($table, $where);
$return = true;
$this->commit();
} catch (Exception $e) {
error_log(get_class($e) . " - Caught: " . $e->getMessage());
error_log($e->getTraceAsString());
$this->rollBack();
throw $e;
}
return $return;
}
示例7: removeNode
public function removeNode($ID)
{
if (!($info = $this->getNodeInfo($ID))) {
return false;
}
if ($ID) {
$this->_db->beginTransaction();
try {
// DELETE FROM my_tree WHERE left_key >= $left_key AND right_key <= $right_key
$this->_db->delete($this->_table, $this->_left . ' >= ' . $info[$this->_left] . ' AND ' . $this->_right . ' <= ' . $info[$this->_right]);
// UPDATE my_tree SET left_key = IF(left_key > $left_key, left_key – ($right_key - $left_key + 1), left_key), right_key = right_key – ($right_key - $left_key + 1) WHERE right_key > $right_key
$sql = 'UPDATE ' . $this->_table . '
SET
' . $this->_left . ' = IF(' . $this->_left . ' > ' . $info[$this->_left] . ', ' . $this->_left . ' - ' . ($info[$this->_right] - $info[$this->_left] + 1) . ', ' . $this->_left . '),
' . $this->_right . ' = ' . $this->_right . ' - ' . ($info[$this->_right] - $info[$this->_left] + 1) . '
WHERE
' . $this->_right . ' > ' . $info[$this->_right];
$this->_db->query($sql);
$this->_db->commit();
return new Varien_Db_Tree_Node($info, $this->getKeys());
} catch (Exception $e) {
$this->_db->rollBack();
echo $e->getMessage();
}
}
}
示例8: isValid
/**
* Returns true if and only if $value meets the validation requirements
*
* If $value fails validation, then this method returns false, and
* getMessages() will return an array of messages that explain why the
* validation failed.
*
* @param mixed $value
* @return boolean
* @throws \Zend_Valid_Exception If validation of $value is impossible
*/
public function isValid($value)
{
if ($throttleSettings = $this->project->getAskThrottleSettings()) {
// Prune the database for (very) old attempts
$where = $this->db->quoteInto('gta_datetime < DATE_SUB(NOW(), INTERVAL ? second)', $throttleSettings['period'] * 20);
$this->db->delete('gems__token_attempts', $where);
// Retrieve the number of failed attempts that occurred within the specified window
$select = $this->db->select();
$select->from('gems__token_attempts', array(new \Zend_Db_Expr('COUNT(*) AS attempts'), new \Zend_Db_Expr('UNIX_TIMESTAMP(MAX(gta_datetime)) - UNIX_TIMESTAMP() AS last')))->where('gta_datetime > DATE_SUB(NOW(), INTERVAL ? second)', $throttleSettings['period']);
$attemptData = $this->db->fetchRow($select);
$remainingDelay = $attemptData['last'] + $throttleSettings['delay'];
// \MUtil_Echo::track($throttleSettings, $attemptData, $remainingDelay);
if ($attemptData['attempts'] > $throttleSettings['threshold'] && $remainingDelay > 0) {
$this->logger->log("Possible token brute force attack, throttling for {$remainingDelay} seconds", \Zend_Log::ERR);
$this->_messages = $this->translate->_('The server is currently busy, please wait a while and try again.');
return false;
}
}
// The pure token check
if ($this->isValidToken($value)) {
return true;
}
$max_length = $this->tracker->getTokenLibrary()->getLength();
$this->db->insert('gems__token_attempts', array('gta_id_token' => substr($value, 0, $max_length), 'gta_ip_address' => $this->getRequest()->getClientIp()));
return false;
}
示例9: resetState
/**
* reset list of stored id
*
* @param Syncope_Model_IDevice|string $_deviceId
* @param Syncope_Model_IFolder|string $_folderId
*/
public function resetState($_deviceId, $_folderId)
{
$deviceId = $_deviceId instanceof Syncope_Model_IDevice ? $_deviceId->id : $_deviceId;
$folderId = $_folderId instanceof Syncope_Model_IFolder ? $_folderId->id : $_folderId;
$where = array($this->_db->quoteInto($this->_db->quoteIdentifier('device_id') . ' = ?', $deviceId), $this->_db->quoteInto($this->_db->quoteIdentifier('folder_id') . ' = ?', $folderId));
$this->_db->delete($this->_tablePrefix . 'content', $where);
}
示例10: removeInactiveRounds
/**
* Remove the unanswered tokens for inactive rounds.
*
* @param \Gems_Tracker_RespondentTrack $respTrack The respondent track to check
* @param int $userId Id of the user who takes the action (for logging)
* @return int The number of tokens changed by this code
*/
protected function removeInactiveRounds(\Gems_Tracker_RespondentTrack $respTrack, $userId)
{
$qTrackId = $this->db->quote($this->_trackId);
$qRespTrackId = $this->db->quote($respTrack->getRespondentTrackId());
$orgId = $this->db->quote($respTrack->getOrganizationId());
$where = "gto_start_time IS NULL AND\n gto_id_respondent_track = {$qRespTrackId} AND\n gto_id_round != 0 AND\n gto_id_round IN (SELECT gro_id_round\n FROM gems__rounds\n WHERE (gro_active = 0 OR gro_organizations NOT LIKE CONCAT('%|',{$orgId},'|%')) AND\n gro_id_track = {$qTrackId})";
return $this->db->delete('gems__tokens', $where);
}
示例11: delete
/**
* Deletes existing rows.
*
* @param array|string $where SQL WHERE clause(s).
* @return int The number of rows deleted.
*/
public function delete($where)
{
if (!isset($where)) {
throw new Exception('condition is null');
}
$where = $this->_translateToZendWhere($where);
return $this->_adapter->delete($this->_tableName, $where);
}
示例12: delete
/**
* Delete row.
*
* @return bool Row deleted successfull.
*/
public function delete(Days_Db_Row $row)
{
if (!isset($row->id)) {
throw new Days_Exception('Not specified `id` for row to delete');
}
$where = $this->_db->quoteInto("_{$this->_name}_id=?", $row->id);
return $this->_db->delete($this->_name, $where) > 0;
}
示例13: removeApplication
/**
* remove all relations for application
*
* @param string $applicationName
*
* @return void
*/
public function removeApplication($applicationName)
{
$tableName = SQL_TABLE_PREFIX . 'relations';
$select = $this->_db->select()->from($tableName)->columns('rel_id')->where($this->_db->quoteIdentifier('own_model') . ' LIKE ?', $applicationName . '_%');
$relation_ids = $this->_db->fetchCol($select);
if (is_array($relation_ids) && count($relation_ids) > 0) {
$this->_db->delete($tableName, $this->_db->quoteInto($this->_db->quoteIdentifier('rel_id') . ' IN (?)', $relation_ids));
}
}
示例14: _migrateFromOldCalendar
private function _migrateFromOldCalendar()
{
$db = $this->_db;
$this->_oldCalId = $db->select()->from('module')->where('name = "Calendar"')->query()->fetchColumn();
if (!in_array('calendar', $db->listTables()) || empty($this->_oldCalId)) {
throw new Exception('Old Calendar is gone, cannot migrate');
}
$this->_newCalId = $db->select()->from('module')->where('name = "Calendar"')->query()->fetchColumn();
$this->_db->delete('calendar2');
$this->_copyEvents();
$this->_updateSingleChangedOccurrences();
$this->_updateUsers();
$this->_updateRights();
$this->_updateLastEnd();
$this->_updateTags();
$this->_updateHistory();
$this->_regenerateSearch();
}
示例15: _alterEnumValues
/**
*
* @param array $enumValues
* @param boolean $reverse
*/
protected function _alterEnumValues(array $enumValues, $reverse = false)
{
foreach ($enumValues as $tableName => $fields) {
if ($this->_isTableExists($tableName)) {
$table = $this->_db->describeTable($tableName);
foreach ($fields as $fieldName => $fieldEnums) {
if (!isset($table[$fieldName])) {
continue;
}
preg_match('/^enum\\((.*)\\)$/', $table[$fieldName]['DATA_TYPE'], $matches);
foreach (explode(',', $matches[1]) as $value) {
$enums[] = trim($value, "'");
}
$newEnums = $enums;
if (isset($fieldEnums['add'])) {
if (!$reverse) {
foreach ($fieldEnums['add'] as $fieldEnum) {
$newEnums[] = $fieldEnum;
}
} else {
foreach ($fieldEnums['add'] as $fieldEnum) {
$this->_db->delete($tableName, $fieldName . ' = \'' . $fieldEnum . '\'');
}
$newEnums = array_diff($newEnums, $fieldEnums['add']);
}
$newEnums = array_unique($newEnums);
}
if (isset($fieldEnums['remove'])) {
if (!$reverse) {
foreach ($fieldEnums['remove'] as $fieldEnum) {
$this->_db->delete($tableName, $fieldName . ' = \'' . $fieldEnum . '\'');
}
$newEnums = array_diff($newEnums, $fieldEnums['remove']);
} else {
foreach ($fieldEnums['remove'] as $fieldEnum) {
$newEnums[] = $fieldEnum;
}
}
$newEnums = array_unique($newEnums);
}
sort($enums);
sort($newEnums);
if ($enums != $newEnums) {
foreach ($newEnums as &$value) {
$value = '\'' . $value . '\'';
}
$table[$fieldName]['DATA_TYPE'] = 'enum(' . implode(',', $newEnums) . ')';
$this->_alterTable($table[$fieldName]);
}
}
}
}
}