本文整理汇总了PHP中DB::update方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::update方法的具体用法?PHP DB::update怎么用?PHP DB::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Memperbarui record tertentu.
*
* @return boolean
*/
public function update($id, $data = [])
{
try {
$this->db->update($this->table, $id, $data);
return true;
} catch (Exception $e) {
die($e->getMessage);
}
}
示例2: update
public function update($tableid, $val, $data)
{
if (!$data) {
return;
}
return DB::update($this->_get_table($tableid), $data, DB::field($this->_pk, $val));
}
示例3: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('posts', function (Blueprint $table) {
$table->renameColumn('pgp_fp', 'user_fp');
$table->index('user_fp');
});
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('pgp_fp', 'user_fp');
$table->index('user_fp');
});
Schema::table('bumps', function (Blueprint $table) {
$table->string('user_fp', 40)->default('');
$table->index('user_fp');
});
Schema::table('subs', function (Blueprint $table) {
$table->string('user_fp', 40)->default('');
$table->string('sub_fp', 40)->default('');
$table->index('user_fp');
});
Schema::table('messages', function (Blueprint $table) {
$table->string('user_fp', 40)->default('');
$table->index('user_fp');
});
Schema::table('apikeys', function (Blueprint $table) {
$table->string('user_fp', 40)->default('');
});
$queries = ['update posts left join users on posts.user_id = users.id set posts.user_fp = users.user_fp', 'update bumps left join users on bumps.user_id = users.id set bumps.user_fp = users.user_fp', 'update subs left join users on subs.user_id = users.id set subs.user_fp = users.user_fp', 'update subs left join users on subs.subscription_to = users.id set subs.sub_fp = users.user_fp', 'update messages left join users on messages.user_id = users.id set messages.user_fp = users.user_fp', 'update apikeys left join users on apikeys.user_id = users.id set apikeys.user_fp = users.user_fp'];
foreach ($queries as $q) {
DB::update($q);
}
}
示例4: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->dateTime('announcement_expires')->nullable();
});
DB::update(DB::raw("UPDATE users SET announcement_expires = DATE_ADD(announcement_start, INTERVAL 7 DAY) WHERE announcement_start IS NOT NULL"));
}
示例5: update_by_threadtableid
public function update_by_threadtableid($threadtableid, $data, $unbuffered = false, $low_priority = false)
{
if (empty($data)) {
return false;
}
return DB::update($this->_table, $data, DB::field('threadtableid', $threadtableid), $unbuffered, $low_priority);
}
示例6: update_cpgroupid_by_cpgroupid
public function update_cpgroupid_by_cpgroupid($val, $data)
{
if (!is_array($data)) {
return null;
}
return DB::update('common_admincp_member', $data, DB::field('cpgroupid', $val));
}
示例7: action_delete
public function action_delete()
{
$district = $this->get_orm_model('district', $this->_base_url);
$services = $district->services->find_all();
if ($_POST) {
if (Arr::get($_POST, 'submit')) {
$msg = __(Kohana::message('admin', 'district.delete_success'), array(':name' => $district->name));
$query = DB::update('services')->set(array('district_id' => NULL))->where('district_id', '=', $district->id)->execute();
$district->content->delete();
$district->delete();
if (count($services) > 0) {
$msg .= __(Kohana::message('admin', 'metro.delete_success_services'), array(':count' => count($services)));
}
Message::set(Message::SUCCESS, $msg);
}
$this->request->redirect($this->_base_url);
}
$text = __(Kohana::message('admin', 'district.delete_question'), array(':name' => $district->name));
if (count($services) > 0) {
$text .= __(Kohana::message('admin', 'metro.delete_question_services'), array(':count' => count($services)));
}
$this->template->title = 'Удаление округа "' . $district->name . '"';
$this->template->bc['#'] = $this->template->title;
$this->view = View::factory('backend/delete')->set('from_url', $this->_base_url)->set('title', $this->template->title)->set('text', $text);
$this->template->content = $this->view;
}
示例8: login
function login()
{
$accessToken = Url::get('accessToken', '');
$login_info = json_decode(file_get_contents('http://ids.cpvm.vn/services/api/users/check_open_user.php?o=' . $accessToken . '&t=2'));
if ($login_info->s) {
$token = $login_info->v->t;
//Lay thong tin user theo token
$info = json_decode(file_get_contents('http://ids.cpvm.vn/services/api/users/userinfo.php?t=' . $token));
if ($info->s) {
$u = $info->v->u;
$user = User::getUserById($u->id);
if (!$user) {
// user chua co trong db => clone
$data = array('id' => $u->id, 'user_name' => $u->un, 'full_name' => $u->fn, 'avatar_url' => $u->av);
$id = DB::insert('account', $data);
} else {
DB::update('account', array('full_name' => $u->fn), 'id=' . $u->id);
}
$u->t = $token;
//dang nhap
User::LogIn2((array) $u);
$_SESSION['token'] = $token;
echo 1;
} else {
echo 0;
}
} else {
echo 0;
}
exit;
}
示例9: update_by_find
public function update_by_find($find, $data)
{
if (!empty($find) && !empty($data) && is_array($data)) {
return DB::update($this->_table, $data, DB::field('find', $find));
}
return 0;
}
示例10: replace_orgid_by_uid
public function replace_orgid_by_uid($uid, $orgarr)
{
$orgids = array();
foreach ($orgarr as $key => $value) {
$orgids[] = $key;
}
$Oorgids = self::fetch_orgids_by_uid($uid);
if (!is_array($orgids)) {
$orgids = array($orgids);
}
$insertids = array_diff($orgids, $Oorgids);
$delids = array_diff($Oorgids, $orgids);
$updateids = array_diff($orgids, $delids, $insertids);
if ($delids) {
DB::delete($this->_table, "uid='{$uid}' and orgid IN (" . dimplode($delids) . ")");
}
foreach ($insertids as $orgid) {
if ($orgid > 0) {
parent::insert(array("orgid" => $orgid, 'jobid' => $orgarr[$orgid], 'uid' => $uid, 'dateline' => TIMESTAMP), 0, 1);
}
}
foreach ($updateids as $orgid) {
if ($orgid > 0) {
DB::update($this->_table, array('jobid' => $orgarr[$orgid]), "orgid='{$orgid}' and uid='{$uid}'");
}
}
wx_updateUser($uid);
return true;
}
示例11: insert
function insert($arr, $id)
{
global $_G;
if (!$arr) {
return false;
}
$arr['nick'] = $arr['nick'] ? trim($arr['nick']) : '';
$arr['sid'] = $arr['sid'] ? trim($arr['sid']) : '';
$arr['title'] = $arr['title'] ? trim($arr['title']) : '';
$arr['desc'] = $arr['desc'] ? trim($arr['desc']) : '';
$arr['pic_path'] = $arr['pic_path'] ? trim($arr['pic_path']) : '';
$arr['picurl'] = $arr['picurl'] ? trim($arr['picurl']) : '';
$arr['banner'] = $arr['banner'] ? trim($arr['banner']) : '';
$arr['url'] = $arr['url'] ? trim($arr['url']) : '';
$arr['start_time'] = dmktime($arr['start_time']);
$arr['end_time'] = dmktime($arr['end_time']);
$arr['zk'] = floatval($arr['zk']);
$arr['cate'] = intval($arr['cate']);
$arr['shop_type'] = intval($arr['shop_type']);
$arr['hide'] = intval($arr['hide']);
$arr['sort'] = intval($arr['sort']);
if ($id > 0) {
$id = DB::update('shop', $arr, 'id=' . $id);
api_post(array('a' => 'update', 'table' => 'shop', 'data' => $arr, 'pre_key' => 'sid', 'id' => $arr['sid'], 'cache' => 'channels,all_channel'));
} else {
$arr['dateline'] = TIMESTAMP;
$id = DB::insert('shop', $arr, 1);
if ($id > 0) {
api_post(array('a' => 'insert', 'table' => 'shop', 'data' => $arr, 'cache' => 'shop,shop_type', 'id' => $id));
}
}
return $id;
}
示例12: save
public function save($isNewUser = false)
{
//create a new database object.
$db = new DB();
$username = mysql_real_escape_string($this->username);
$email = mysql_real_escape_string($this->email);
$firstName = mysql_real_escape_string($this->firstName);
$lastName = mysql_real_escape_string($this->lastName);
$link = mysql_real_escape_string($this->link);
$blog = mysql_real_escape_string($this->blog);
//if the user is already registered and we're
//just updating their info.
if (!$isNewUser) {
//set the data array
$data = array("username" => "'{$username}'", "password" => "'{$this->hashedPassword}'", "email" => "'{$email}'", "firstName" => "'{$firstName}'", "lastName" => "'{$lastName}'", "link" => "'{$link}'", "blog" => "'{$blog}'");
//update the row in the database
$db->update($data, 'users', 'id = ' . $this->id);
} else {
//if the user is being registered for the first time.
$data = array("username" => "'{$username}'", "password" => "'{$this->hashedPassword}'", "email" => "'{$email}'", "link" => "'{$link}'", "blog" => "'{$blog}'", "firstName" => "'{$firstName}'", "lastName" => "'{$lastName}'", "join_date" => "'" . date("Y-m-d H:i:s", time()) . "'");
$this->id = $db->insert($data, 'users');
$this->joinDate = time();
}
return true;
}
示例13: update_by_aid
public function update_by_aid($aid, $data)
{
if (($aid = dintval($aid)) && !empty($data) && is_array($data)) {
return DB::update($this->_table, $data, array('aid' => $aid));
}
return 0;
}
示例14: update
public function update($tid, $pid, $data)
{
if (empty($data) || !is_array($data)) {
return false;
}
DB::update('forum_trade', $data, array('tid' => $tid, 'pid' => $pid));
}
示例15: deleteTopic
/**
* {@inheritDoc}
*/
public function deleteTopic(EloquentTopic $topic)
{
// Clean and convert ids
$ids = implode(',', array_filter($topic->pathExplode(), 'is_numeric'));
$query = "UPDATE forums\n\t\t\t SET posts = posts - ?, topics_count = topics_count - 1\n\t\t\t WHERE id IN ({$ids})";
return \DB::update($query, [$topic->posts_count]);
}