本文整理汇总了PHP中Db::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::update方法的具体用法?PHP Db::update怎么用?PHP Db::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unpublish
public static function unpublish($id)
{
$id = Typo::int($id);
$ins = array('table' => 'posts', 'id' => $id, 'key' => array('status' => '0'));
$post = Db::update($ins);
return $post;
}
示例2: reset_keywords
function reset_keywords($new_kws_str, $type = 'equal')
{
$ks = $this->keywords();
$old_kws = array();
foreach ($ks as $k) {
$old_kws[] = $k->keyword;
}
$ps = explode(',', $new_kws_str);
$kws = array();
foreach ($ps as $p) {
$p = trim($p);
if (strlen($p)) {
$kws[$p] = $p;
}
}
$to_del = array_diff($old_kws, $kws);
foreach ($to_del as $k) {
Db::escape($k);
$sql = "delete from wx_reply_keywords where item_id='{$this->id}' and keyword='{$k}'";
Db::query($sql);
}
$to_add = array_diff($kws, $old_kws);
foreach ($to_add as $k) {
WxReplyKeyword::save(array('type' => $type, 'keyword' => $k, 'item_id' => $this->id));
}
$sql = "update " . WxReplyKeyword::table() . " set type='{$type}' where item_id='{$this->id}'";
Db::update($sql);
}
示例3: update
public static function update()
{
$post = Input::post(array('sitename', 'description', 'theme', 'twitter', 'home_page', 'posts_page'));
$errors = array();
if (empty($post['sitename'])) {
$errors[] = 'You need a site sitename';
}
if (empty($post['description'])) {
$errors[] = 'You need a site description';
}
if (empty($post['theme'])) {
$errors[] = 'You need a theme';
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
$post['sitename'] = htmlentities($post['sitename']);
$post['description'] = htmlentities($post['description']);
foreach ($post as $key => $value) {
Db::update('meta', array('value' => $value), array('key' => $key));
}
Notifications::set('success', 'Your metadata has been updated');
return true;
}
示例4: put
/**
* @return integer
*/
public function put()
{
if (null === $this->identifier) {
throw new Exception('Identifier not found.');
}
$fields = array();
$update = $this->properties[$this->identifier]->has();
$return = 0;
foreach ($this->properties as $name => $instance) {
if (!is_subclass_of($instance, 'Property')) {
continue;
}
if ($instance instanceof PropertyIdentifier) {
continue;
}
$fields[$name] = $instance->get();
}
if ($update) {
$return = $affected = $this->db->update($this->table, $fields, array($this->identifier => $this->properties[$this->identifier]->get()));
} else {
$return = $inserted = $this->db->insert($this->table, $fields);
if ($inserted) {
$this->properties[$this->identifier]->set($inserted);
}
}
$this->hash = Model::hash($this->properties);
return $return;
}
示例5: updateSetting
/**
* 更新信息
*
* @param array $param 更新数据
* @return bool 布尔类型的返回结果
*/
public function updateSetting($param)
{
if (empty($param)) {
return false;
}
/**
* 因为是数值更新,所以需要循环数组
*/
if (is_array($param)) {
foreach ($param as $k => $v) {
$tmp = array();
$specialkeys_arr = array('statistics_code', 'qq_appcode', 'share_qqzone_appcode', 'share_sinaweibo_appcode');
$tmp['value'] = in_array($k, $specialkeys_arr) ? htmlentities($v, ENT_QUOTES) : $v;
$where = " name = '" . $k . "'";
$result = Db::update('setting', $tmp, $where);
if ($result !== true) {
return $result;
}
}
@unlink(BasePath . DS . 'cache' . DS . 'setting.php');
return true;
} else {
return false;
}
}
示例6: update
public static function update()
{
$post = Input::post(array('sitename', 'description', 'theme', 'twitter', 'home_page', 'posts_page', 'auto_published_comments', 'posts_per_page'));
$errors = array();
if (empty($post['sitename'])) {
$errors[] = 'You need a site sitename';
}
if (empty($post['description'])) {
$errors[] = 'You need a site description';
}
if (empty($post['theme'])) {
$errors[] = 'You need a theme';
}
// auto publish comments
$post['auto_published_comments'] = $post['auto_published_comments'] ? 1 : 0;
// format posts per page, must be a whole number above 1 defaults to 10 if a invalid number is entered
$post['posts_per_page'] = ($posts_per_page = intval($post['posts_per_page'])) > 0 ? $posts_per_page : 10;
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
foreach ($post as $key => $value) {
Db::update('meta', array('value' => $value), array('key' => $key));
}
Notifications::set('success', 'Your metadata has been updated');
return true;
}
示例7: updateCart
/**
* 更新购物车
*
* @param array $param 商品信息
*/
public function updateCart($param, $condition)
{
$array = array();
//得到条件语句
$condition_str = $this->getCondition($condition);
$result = Db::update('cart', $param, $condition_str);
return $result;
}
示例8: update
public function update()
{
if (empty($this->id)) {
throw new Exception('Update error - Undefined photo id');
}
return Db::update('UPDATE photo SET quarter_id = :quarter_id, src = :src, info_id = :info_id, user_id = :user_id
WHERE id = :id', array('quarter_id' => $this->quarter_id, 'src' => $this->src, 'info_id' => $this->info_id, 'user_id' => $this->user_id, 'id' => (int) $this->id));
}
示例9: updatestat
/**
* 更新统计表
*
* @param array $param 条件数组
*/
public function updatestat($param)
{
if (empty($param)) {
return false;
}
$result = Db::update($param['table'], array($param['field'] => array('sign' => 'increase', 'value' => $param['value'])), $param['where']);
return $result;
}
示例10: tracelogEdit
/**
* 更新动态记录
* @param array $param 修改信息数组
* @param array $condition 条件数组
*/
public function tracelogEdit($param,$condition){
if(empty($param)) {
return false;
}
//得到条件语句
$condition_str = $this->getCondition($condition);
$result = Db::update('sns_tracelog',$param,$condition_str);
return $result;
}
示例11: save
public function save()
{
$params = json_encode($this->settings);
$updateQuery = 'UPDATE jos_extensions SET params = ? WHERE `type`=\'component\' AND `element` = \'com_hubgraph\'';
$insertQuery = 'INSERT INTO jos_extensions(name, `type`, `element`, params) VALUES (\'HubGraph\', \'component\', \'com_hubgraph\', ?)';
if (!Db::update($updateQuery, array($params))) {
Db::execute($insertQuery, array($params));
}
}
示例12: editSharestore
/**
* 更新分享店铺信息
* @param $param 更新内容
* @param $condition 更新条件
*/
public function editSharestore($param,$condition) {
if(empty($param)) {
return false;
}
//得到条件语句
$condition_str = $this->getCondition($condition);
$result = Db::update('sns_sharestore',$param,$condition_str);
return $result;
}
示例13: updateZtcOne
/**
* 直通车申请信息修改
*
* @param array $param 修改信息数组
* @param int $ztc_id 团购商品id
*/
public function updateZtcOne($param, $condition)
{
if (empty($param)) {
return false;
}
//得到条件语句
$condition_str = $this->getCondition($condition);
$result = Db::update('ztc_goods', $param, $condition_str);
return $result;
}
示例14: update
public function update()
{
$values = $this->values;
if (!isset($values['id'])) {
return false;
}
$id = $values['id'];
unset($values['id']);
return Db::update($this->table, $values, array($this->index => $id));
}
示例15: editGoodsEval
/**
* 更新商品评分信息
*/
public function editGoodsEval($param, $condition)
{
if (empty($param)) {
return false;
}
//得到条件语句
$condition_str = $this->getGoodsEvalCondition($condition);
$result = Db::update('evaluate_goods', $param, $condition_str);
return $result;
}