本文整理汇总了PHP中waModel::updateById方法的典型用法代码示例。如果您正苦于以下问题:PHP waModel::updateById方法的具体用法?PHP waModel::updateById怎么用?PHP waModel::updateById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waModel
的用法示例。
在下文中一共展示了waModel::updateById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save this record to database: insert or update depending on whether record exists in DB.
* Silently ignores all keys that have no corresponding fields in database table.
*
* @return mixed this record id
* @throws waException when values fail validation
*/
public function save()
{
$this->beforeSave();
$values = array_intersect_key($this->removeStubs()->rec_data, $this->m->getMetadata());
if ($this->id === null) {
$this->id = $this->m->insert($values);
$this[$this->m->getTableId()] = $this->id;
} else {
$this->m->updateById($this->id, $values);
}
$this->afterSave();
$this->merge();
return $this->id;
}
示例2: updateById
public function updateById($id, $data, $options = null, $return_object = false)
{
if ($cache = wa()->getCache()) {
$cache->delete('block_' . $id);
}
return parent::updateById($id, $data, $options, $return_object);
}
示例3: save
/**
* Save this record to database: insert or update depending on whether record exists in DB.
* Silently ignores all keys that have no corresponding fields in database table.
*
* @return mixed this record id
* @throws waException when values fail validation
*/
public function save()
{
$this->beforeSave();
$values = array_intersect_key($this->removeStubs()->rec_data, $this->m->getMetadata());
$do_insert = true;
$id = $this->getId();
// Force saving with given id, if specified during construction
$id || ($id = $this->persistent->ifset($this->m->getTableId()));
// Update if record exists
if ($id && $this->exists()) {
if (!$values) {
$do_insert = false;
} else {
$result = $this->m->updateById($this->id, $values, null, true);
if ($result->affectedRows()) {
$do_insert = false;
if (!empty($values[$this->m->getTableId()])) {
$this->id = $values[$this->m->getTableId()];
}
} else {
// Make sure the record exists
if ($row = $this->m->getById($this->id)) {
$do_insert = false;
$this->persistent->setAll($row);
} else {
$this->clearPersistent();
}
}
}
} else {
if ($id && empty($values[$this->m->getTableId()])) {
// id was given to constructor, but no such record exists
$values[$this->m->getTableId()] = $id;
}
}
// No row in database yet: insert
if ($do_insert) {
unset($this->persistent[$this->m->getTableId()]);
$this->id = $this->m->insert($values);
$this[$this->m->getTableId()] = $this->id;
}
$this->afterSave();
$this->merge();
return $this->id;
}
示例4: updateById
public function updateById($id, $data, $options = null, $return_object = false)
{
if ($cache = wa('shop')->getCache()) {
$cache->deleteGroup('sets');
}
return parent::updateById($id, $data, $options, $return_object);
}