本文整理汇总了PHP中Zend_Db_Table::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table::update方法的具体用法?PHP Zend_Db_Table::update怎么用?PHP Zend_Db_Table::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Table
的用法示例。
在下文中一共展示了Zend_Db_Table::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reorder
/**
* Move down/up setting into the table
*/
public function reorder($setting, $table, $sens)
{
global $logger;
$cur_id = $setting->id;
$other_id = $sens == 'up' ? $cur_id - 1 : $cur_id + 1;
$oTable = new Zend_Db_Table($table);
$where_cur = $oTable->getAdapter()->quoteInto('id = ?', $cur_id);
$where_other = $oTable->getAdapter()->quoteInto('id = ?', $other_id);
$where_tmp = $oTable->getAdapter()->quoteInto('id = ?', 999);
$oTable->update(array('id' => 999), $where_cur);
$oTable->update(array('id' => $cur_id), $where_other);
$result = $oTable->update(array('id' => $other_id), $where_tmp);
$logger->log("Reorder setting {$table}={$setting->id} {$sens}", Zend_Log::INFO);
return $result;
}
示例2: save
/**
* Saves the properties to the database.
*
* This performs an intelligent insert/update, and reloads the
* properties with fresh data from the table on success.
*
* @return int 0 on failure, 1 on success.
*/
public function save()
{
// convenience var for the primary key name
$primary = $this->_info['primary'];
// check the primary key value for insert/update
if (empty($this->_data[$primary])) {
// no primary key value, must be an insert.
// make sure it's null.
$this->_data[$primary] = null;
// attempt the insert.
$result = $this->_table->insert($this->_data);
if (is_numeric($result)) {
// insert worked, refresh with data from the table
$this->_data[$primary] = $result;
$this->_refresh();
}
// regardless of success return the result
return $result;
} else {
// has a primary key value, update only that key.
$where = $this->_db->quoteInto("{$primary} = ?", $this->_data[$primary]);
// return the result of the update attempt,
// no need to update the row object.
$result = $this->_table->update($this->_data, $where);
if (is_int($result)) {
// update worked, refresh with data from the table
$this->_refresh();
}
}
}
示例3: update
public function update(array $data, $where)
{
if (empty($data['updated_at'])) {
$data['updated_at'] = date('Y-m-d h:i:s');
}
return parent::update($data, $where);
}
示例4: updateAd
public function updateAd(array $data, $id)
{
$table = new Zend_Db_Table('ads');
$fields = $table->info(Zend_Db_Table_Abstract::COLS);
foreach ($data as $field => $value) {
if (!in_array($field, $fields)) {
unset($data[$field]);
}
}
return $table->update($data, 'id = ' . (int) $id);
}
示例5: update
public function update($id, array $data, $log = true)
{
$data['updated_at'] = get_time();
if (is_session('user_id')) {
$data['updated_by'] = get_session('user_id');
}
$where = $this->getAdapter()->quoteInto('id = ?', $id);
parent::update($data, $where);
if ($log) {
log_sql($this->_name, $id, 'updated', $data);
set_session('notice', 'current record saved');
}
}
示例6: save
/**
* Save object in DB
*
* @return HumanHelp_Model_Comment
*/
public function save()
{
$table = new Zend_Db_Table('comments');
if (isset($this->_id)) {
// Update
$table->update($this->_data, $table->getAdapter()->quoteInto('id = ?', $this->_id));
} else {
// Insert
$table->insert($this->_data);
$this->_id = $table->getAdapter()->lastInsertId('comments', 'id');
}
return $this;
}
示例7: update
/**
* Overwrites the update method to allow the second param ($where clause)
* to be null, which would then generate the where clause with the values
* of the primary keys
*
* @param array $data
* @param mixed $where
* @return result from update
*/
public function update(array $data, $where)
{
if (is_null($where)) {
$primary = is_array($this->_primary) ? $this->_primary : array($this->_primary);
foreach ($primary as $key) {
if (!is_null($where)) {
$where .= ' AND ';
}
if (!isset($data[$key])) {
throw new Ot_Exception_Input("Primary key {$key} not set");
}
$where .= $this->getAdapter()->quoteInto($key . ' = ?', $data[$key]);
}
}
return parent::update($data, $where);
}
示例8: saveMetadataValue
/**
* Save a metadata value, will update the row if it exists, otherwise insert.
*
* @param MetadataDao $metadataDao
* @return bool
* @throws Zend_Exception
*/
public function saveMetadataValue($metadataDao)
{
if (!$metadataDao instanceof MetadataDao) {
throw new Zend_Exception('Should be a metadata.');
}
$cols = array('metadata_id' => $metadataDao->getKey(), 'itemrevision_id' => $metadataDao->getItemrevisionId());
$data['value'] = $metadataDao->getValue();
$tablename = $this->getTableValueName($metadataDao->getMetadatatype());
$table = new Zend_Db_Table(array('name' => $tablename, 'primary' => 'metadata_id'));
if ($this->getMetadataValueExists($metadataDao)) {
$wheres = array();
foreach ($cols as $col => $val) {
$wheres[$col . '=?'] = $val;
}
$table->update($data, $wheres);
} else {
foreach ($cols as $col => $val) {
$data[$col] = $val;
}
$table->insert($data);
}
return true;
}
示例9: update
public function update(array $data)
{
$table = new Zend_Db_Table('users');
$where = $table->getAdapter()->quoteInto('id= ?', (int) $data['id']);
$table->update($data, $where);
}
示例10: update
/**
* 按ID更改新闻信息
*
* @param array $arrayUpdate
* @param int $id
*/
public function update($arrayUpdate, $id, $isCleanCache = true)
{
try {
//开启事务
$this->getAdapter()->beginTransaction();
//如果需要删除缓存
if ($isCleanCache) {
//清除指定标识的缓存
$this->_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(strtolower($this->_name)));
$this->_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(strtolower($this->_name . '_findById_' . $id)));
}
//指定查询条件
$where = $this->getAdapter()->quoteInto('id = ?', $id);
//调用父类方法更改数据
parent::update($arrayUpdate, $where);
//提交查询
$this->getAdapter()->commit();
} catch (Zend_Exception $e) {
echo $e->getMessage();
//如果出错则事务回滚
$this->getAdapter()->rollBack();
}
}
示例11: update
public function update(array $data, $where)
{
$metadata = $this->info();
$columns = $metadata['cols'];
$timestamp = date("Y-m-d H:i:s");
if (in_array('updated_on', $columns)) {
if (!in_array('updated_on', $data)) {
$data['updated_on'] = $timestamp;
}
}
$params = array("data" => $data, "where" => $where, "errors" => $this->_errors, "table" => $this->_name, "module" => $this->_module_id, "primary" => $this->_primary);
if (isset($this->_use_adapter)) {
$params['use_adapter'] = $this->_use_adapter;
} else {
$params['use_adapter'] = null;
}
// rethrowing exceptions here because of a weird php issue where the trace isn't getting passed
try {
$params = Bolts_Plugin::getInstance()->doFilter('db_table_update', $params);
} catch (Exception $e) {
throw $e;
}
if (count($params['errors']) == 0) {
return parent::update($params['data'], $params['where']);
} else {
$this->_errors = $params['errors'];
return false;
}
}
示例12: markAsRead
/**
* mark a thread as read by setting the unread counter to zero
*
* @param thread_id
*/
public function markAsRead($id, $user_id)
{
if (!$id) {
return null;
}
$threads_table = new Zend_Db_Table('threads');
$data = array('unread' => '0');
$where = array('id = ?' => $id, 'last_speaker != ?' => $user_id);
$threads_table->update($data, $where);
}
示例13: toggleTriggersStatuses
/**
* Switching trigger statuses according to plugin status
* @param $pluginName Name of plugin
* @param $status Plugin status
* @return Application_Model_Mappers_EmailTriggersMapper
*/
public function toggleTriggersStatuses($pluginName, $status)
{
$triggers = $this->_getTriggers($pluginName);
if (!empty($triggers)) {
$triggersTable = new Zend_Db_Table('email_triggers');
$triggersTable->getAdapter()->beginTransaction();
foreach ($triggers as $trigger) {
$triggersTable->update(array('enabled' => $status == Application_Model_Models_Plugin::DISABLED ? self::TRIGGER_STATUS_DISABLED : self::TRIGGER_STATUS_ENABLED), array('trigger_name = ?' => $trigger['trigger_name'], 'observer = ?' => $trigger['observer']));
}
$triggersTable->getAdapter()->commit();
}
return $this;
}
示例14: _update
public function _update()
{
parent::update($this->attributes, $this->siteDbAdapter->quoteInto($this->pkname . ' = ?', $this->pk));
return $this->pk;
}
示例15: update
public function update(array $data, $where)
{
// add a timestamp
/*
if (empty($data['update_date'])) {
$data['update_date'] = time();
}
*/
//$id = $this->getMasterAdapter();
$this->_db = CrFramework_Db_Control::getAdapter('write');
$this->setDefaultAdapter($this->_db);
return parent::update($data, $where);
}