update() public méthode

更新记录
public update ( mixed $data, array $options ) : false | integer
$data mixed 数据
$options array 表达式
Résultat false | integer | integer
Exemple #1
0
 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;
 }
Exemple #2
0
 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);
 }
 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;
 }
Exemple #4
0
 /**
  * @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;
 }
Exemple #5
0
 /**
  * 更新信息
  *
  * @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;
     }
 }
Exemple #6
0
 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;
 }
Exemple #7
0
 /**
  * 更新购物车 
  *
  * @param	array	$param 商品信息
  */
 public function updateCart($param, $condition)
 {
     $array = array();
     //得到条件语句
     $condition_str = $this->getCondition($condition);
     $result = Db::update('cart', $param, $condition_str);
     return $result;
 }
    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));
    }
Exemple #9
0
 /**
  * 更新统计表
  *
  * @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;
 }
Exemple #10
0
	/**
	 * 更新动态记录
	 * @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;
	}
Exemple #11
0
 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));
     }
 }
Exemple #12
0
	/**
	 * 更新分享店铺信息
	 * @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;
	}
Exemple #13
0
 /**
  * 直通车申请信息修改
  *
  * @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;
 }
Exemple #14
0
 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));
 }
Exemple #15
0
 /**
  * 更新商品评分信息
  */
 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;
 }
Exemple #16
0
 /**
  * 更新充值卡使用状态
  *
  */
 public function updateCard($param, $card_id)
 {
     if (empty($param)) {
         return false;
     }
     $update = false;
     //得到条件语句
     $where = 'card_id=' . $card_id;
     $update = Db::update('pd_gift_card', $param, $where);
     return $update;
 }
Exemple #17
0
 /**
  * 商品信息更新
  *
  * @param	array $param 列表条件
  * @param	int $goods_id 商品id
  */
 public function updateDemand($param, $goods_id)
 {
     if (empty($param)) {
         return false;
     }
     $update = false;
     if (is_array($goods_id)) {
         $goods_id = implode(',', $goods_id);
     }
     //得到条件语句
     $condition_str = "WHERE demand_id in(" . $goods_id . ")";
     $update = Db::update('demand', $param, $condition_str);
     return $update;
 }
Exemple #18
0
 public static function end()
 {
     // cookie details
     $name = Config::get('session.name', 'anchorcms');
     $expire = time() + Config::get('session.expire', 86400);
     $path = Config::get('session.path', '/');
     $domain = Config::get('session.domain', '');
     // update db session
     Db::update('sessions', array('date' => date(DATE_ISO8601), 'ip' => Input::ip_address(), 'ua' => Input::user_agent(), 'data' => serialize(static::$data)), array('id' => static::$id));
     // create cookie with ID
     if (!Cookie::write($name, static::$id, $expire, $path, $domain)) {
         Log::error('Could not write session cookie: ' . static::$id);
     }
 }
Exemple #19
0
 public function changeName()
 {
     $Verify = new Verify();
     $first = trim(strip_tags($_POST['first']));
     $middle = trim(strip_tags($_POST['middle']));
     $last = trim(strip_tags($_POST['last']));
     if (!$Verify->length($first, 255)) {
         $_SESSION['alert'] = 'Your first name is too long to store in the database.';
     } elseif (!$Verify->length($middle, 255)) {
         $_SESSION['alert'] = 'Your middle name is too long to store in the database.';
     } elseif (!$Verify->length($last, 255)) {
         $_SESSION['alert'] = 'Your last name is too long to store in the database.';
     } else {
         $Db = new Db();
         $query = $Db->query('user_name', array(array('user_id', '=', $_SESSION['user'], '')));
         $numrows = mysqli_num_rows($query);
         if ($numrows != 1) {
             $_SESSION['alert'] = 'Error, please try again.';
         } else {
             while ($row = mysqli_fetch_assoc($query)) {
                 if ($first == '') {
                     $first = $row['first'];
                 }
                 if ($middle == '') {
                     $middle = $row['middle'];
                 }
                 if ($last == '') {
                     $last = $row['last'];
                 }
             }
             $updateFirst = $Db->update('user_name', array('first', '=', $first), array(array('user_id', '=', $_SESSION['user'], '')));
             if (!$updateFirst) {
                 $_SESSION['alert'] = 'Error, could not completely update name.';
             } else {
                 $updateMiddle = $Db->update('user_name', array('middle', '=', $middle), array(array('user_id', '=', $_SESSION['user'], '')));
                 if (!$updateMiddle) {
                     $_SESSION['alert'] = 'Error, could not completely update name.';
                 } else {
                     $updateLast = $Db->update('user_name', array('last', '=', $last), array(array('user_id', '=', $_SESSION['user'], '')));
                     if (!$updateLast) {
                         $_SESSION['alert'] = 'Error, could not completely update name.';
                     } else {
                         $_SESSION['alert'] = 'Your name has been updated.';
                     }
                 }
             }
         }
     }
 }
Exemple #20
0
 /**
  * 更新信息
  *
  * @param 
  * @return bool 布尔类型的返回结果
  */
 public function update($condition, $param)
 {
     $map_id = $condition['map_id'];
     if (intval($map_id) < 1) {
         return false;
     }
     $condition_str = $this->getCondition($condition);
     $where = $condition_str;
     if (is_array($param)) {
         $result = Db::update('map', $param, $where);
         return result;
     } else {
         return false;
     }
 }
Exemple #21
0
 public function post()
 {
     $nombres = array('title', 'keywords', 'description');
     $title = Request::getPost('title', $this->title);
     $keywords = Request::getPost('keywords', $this->keywords);
     $description = Request::getPost('description', $this->description);
     foreach ($nombres as $nombre) {
         if (null === $this->{$nombre}) {
             Db::insert('configuracion', array('idioma' => $this->idioma, 'nombre' => $nombre, 'valor' => ${$nombre}));
         } else {
             Db::update('configuracion', array('idioma' => $this->idioma, 'valor' => ${$nombre}), array('nombre' => $nombre));
         }
     }
     return "/admin/configuracion/{$this->idioma}?edited=1";
 }
Exemple #22
0
	/**
	 * 更新水印
	 *
	 * @param array $param 更新数据
	 * @return bool 布尔类型的返回结果
	 */
	public function updateStoreWM($param){
		if (empty($param)){
			return false;
		}
		if (is_array($param)){
			$tmp = array();
			foreach ($param as $k => $v){
				$tmp[$k] = $v;
			}
			$where = " wm_id = '". $param['wm_id'] ."'";
			$result = Db::update('store_watermark',$tmp,$where);
			return $result;
		}else {
			return false;
		}
	}
Exemple #23
0
 public function insertNews($url, $find_elm, $date)
 {
     $db = new Db();
     $content = file_get_html($url);
     foreach ($content->find($find_elm) as $news) {
         if (!empty($news)) {
             $db->insert('news', array('title' => $news->plaintext, 'date' => $date, 'last_update' => date('Y-m-d'), 'news_type' => static::$newsType));
         }
     }
     $settings = $db->query('SELECT * FROM settings WHERE news_type="' . static::$newsType . '"');
     if (!is_array($settings)) {
         $db->insert('settings', array('news_type' => static::$newsType, 'last_update' => date('Y-m-d')));
     } else {
         $db->update('settings', array('last_update' => date('Y-m-d')), array('news_type' => static::$newsType));
     }
 }
 /**
  * 更新模板内容
  *
  * @param array $param 更新参数
  * @return bool 布尔类型的返回结果
  */
 public function update($param)
 {
     if (empty($param)) {
         return false;
     }
     if (is_array($param)) {
         $tmp = array();
         foreach ($param as $k => $v) {
             $tmp[$k] = $v;
         }
         $where = " code = '" . $param['code'] . "'";
         $result = Db::update('mail_msg_temlates', $tmp, $where);
         return $result;
     } else {
         return false;
     }
 }
 /**
  * 更新
  *
  * @param array $param 更新数据
  * @return bool 布尔类型的返回结果
  */
 public function edit($param)
 {
     if (empty($param)) {
         return false;
     }
     if (is_array($param)) {
         $tmp = array();
         foreach ($param as $k => $v) {
             $tmp[$k] = $v;
         }
         $where = " theme_name = '" . $param['theme_name'] . "' and module_name='" . $param['module_name'] . "' ";
         $result = Db::update('store_theme', $tmp, $where);
         return $result;
     } else {
         return false;
     }
 }
 public function update($param)
 {
     if (empty($param)) {
         return false;
     }
     if (is_array($param)) {
         $tmp = array();
         foreach ($param as $k => $v) {
             $tmp[$k] = $v;
         }
         $where = " view_detail_id = '" . $param['view_detail_id'] . "'";
         $result = Db::update('view_detail', $tmp, $where);
         return $result;
     } else {
         return false;
     }
 }
Exemple #27
0
 /**
  * 更新规格信息
  * @param	array $update 更新数据
  * @param	array $param 条件
  * @param	string $table 表名
  * @return	bool
  */
 public function specUpdate($update, $param, $table)
 {
     $condition_str = $this->getCondition($param);
     if (empty($update)) {
         return false;
     }
     if (is_array($update)) {
         $tmp = array();
         foreach ($update as $k => $v) {
             $tmp[$k] = $v;
         }
         $result = Db::update($table, $tmp, $condition_str);
         return $result;
     } else {
         return false;
     }
 }
Exemple #28
0
 public function submit()
 {
     if (Request::hasPost('guardar')) {
         list($this->validationFlag, $this->validation) = Validation::check(array('nombre' => 'required', 'apellido' => 'required'));
         if ($this->validationFlag) {
             $nombre = Request::getPost('nombre');
             $apellido = Request::getPost('apellido');
             $correo = Request::getPost('correo');
             $cargo = Request::getPost('cargo');
             $telOficina = Request::getPost('tel_oficina');
             $telOficinaInt = Request::getPost('tel_oficina_int');
             $telCelular = Request::getPost('tel_celular');
             $telFax = Request::getPost('tel_fax');
             $telCasa = Request::getPost('tel_casa');
             Db::update('personas', array('nombre' => $nombre, 'apellido' => $apellido, 'correo' => $correo, 'cargo' => $cargo, 'tel_oficina' => $telOficina, 'tel_oficina_int' => $telOficinaInt, 'tel_celular' => $telCelular, 'tel_fax' => $telFax, 'tel_casa' => $telCasa, 'fecha_modificacion' => time()), "id_personas = '{$this->idPersonas}'");
             Response::setRedirect("/personas/{$this->idPersonas}");
         }
     }
 }
 public function update($id, $properties)
 {
     foreach ($properties as $key => $value) {
         if ($key == 'login') {
             if (trim($value) == '') {
                 return false;
             }
             if ($this->loginExists($value, $id)) {
                 return false;
             }
         }
         if ($key == 'password') {
             if (trim($value) == '') {
                 return false;
             }
             $properties[$key] = Auth::getPasswordHash()->HashPassword(trim($value));
         }
     }
     return Db::update("users", $properties, "`id` = :id", array(':id' => $id));
 }
Exemple #30
0
 public function submit()
 {
     if (Request::hasPost('guardar')) {
         list($this->validationFlag, $this->validation) = Validation::check(array('nombre' => 'required'));
         if ($this->validationFlag) {
             $nombre = Request::getPost('nombre');
             $direccion1 = Request::getPost('direccion_1');
             $direccion2 = Request::getPost('direccion_2');
             $ciudad = Request::getPost('ciudad');
             $estado = Request::getPost('estado');
             $codPostal = Request::getPost('cod_postal');
             $idPaises = Request::getPost('id_paises');
             $web = Request::getPost('web');
             $telOficina = Request::getPost('tel_oficina');
             $telFax = Request::getPost('tel_fax');
             Db::update('empresas', array('nombre' => $nombre, 'direccion_1' => $direccion1, 'direccion_2' => $direccion2, 'ciudad' => $ciudad, 'estado' => $estado, 'cod_postal' => $codPostal, 'id_paises' => $idPaises, 'web' => $web, 'tel_oficina' => $telOficina, 'tel_fax' => $telFax, 'fecha_modificacion' => time()), "id_empresas = '{$this->idEmpresas}'");
             Response::setRedirect("/empresas/{$this->idEmpresas}");
         }
     }
 }