本文整理汇总了PHP中Zend_Db_Adapter_Pdo_Mysql::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Pdo_Mysql::update方法的具体用法?PHP Zend_Db_Adapter_Pdo_Mysql::update怎么用?PHP Zend_Db_Adapter_Pdo_Mysql::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Adapter_Pdo_Mysql
的用法示例。
在下文中一共展示了Zend_Db_Adapter_Pdo_Mysql::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Updates table rows with specified data based on a WHERE clause.
*
* @param mixed $table The table to update.
* @param array $bind Column-value pairs.
* @param mixed $where UPDATE WHERE clause(s).
* @return int The number of affected rows.
*/
public function update($table = null, array $bind = null, $where = '')
{
if (is_null($table) && is_null($bind) && !strlen($where)) {
return new Harmoni_Db_Update($this);
} else {
return parent::update($table, $bind, $where);
}
}
示例2: _updateOccurrence
/**
* update tag occurrrence
*
* @param Tinebase_Model_Tag|string $tag
* @param integer $toAddOrRemove
*/
protected function _updateOccurrence($tag, $toAddOrRemove)
{
if ($toAddOrRemove == 0) {
return;
}
$tagId = $tag instanceof Tinebase_Model_Tag ? $tag->getId() : $tag;
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " de/increasing tag occurrence of {$tagId} by {$toAddOrRemove}");
}
$quotedIdentifier = $this->_db->quoteIdentifier('occurrence');
if ($toAddOrRemove > 0) {
$toAdd = (int) $toAddOrRemove;
$data = array('occurrence' => new Zend_Db_Expr($quotedIdentifier . ' + ' . $toAdd));
} else {
$toRemove = abs((int) $toAddOrRemove);
$data = array('occurrence' => new Zend_Db_Expr('(CASE WHEN (' . $quotedIdentifier . ' - ' . $toRemove . ') > 0 THEN ' . $quotedIdentifier . ' - ' . $toRemove . ' ELSE 0 END)'));
}
$this->_db->update(SQL_TABLE_PREFIX . 'tags', $data, $this->_db->quoteInto($this->_db->quoteIdentifier('id') . ' = ?', $tagId));
}