本文整理汇总了PHP中db::update方法的典型用法代码示例。如果您正苦于以下问题:PHP db::update方法的具体用法?PHP db::update怎么用?PHP db::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db
的用法示例。
在下文中一共展示了db::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveMail
function saveMail()
{
db::table('mails');
db::where('mail_id', admin::get('id'));
db::update(array('mail_name' => params::get('mail_name'), 'mail_subject' => params::get('mail_subject'), 'mail_content' => params::get('mail_content')));
headers::self();
}
示例2: save
function save()
{
$array = array('news_title' => params::get('news_title'), 'news_content' => params::get('news_content'), 'news_desc' => params::get('news_desc'));
db::table('news');
db::where('news_id', params::get('news_id'));
db::update($array);
headers::self();
}
示例3: newPassword
function newPassword($new_pass)
{
if (!empty($new_pass)) {
db::table('admin_users');
db::where('user_id', ADMIN_USER_ID);
db::update('user_password', md5($new_pass));
}
}
示例4: update
function update($name, $value, $user_id = false)
{
if (!$user_id) {
$user_id = ADMIN_USER_ID;
}
db::table('admin_users');
db::where('user_id', $user_id);
db::update($name, $value);
}
示例5: update_password
function update_password($password)
{
$db = new db();
$user = get_user_data();
$id = $user['id'];
$password = md5($password);
$result = $db->update("users", array("password" => $password), "id = :id", array(":id" => $id));
return $result;
}
示例6: saveNewLearningTime
public function saveNewLearningTime($values)
{
$this->_prepareLearningTimes();
if (isset($values['id'])) {
$id = $values['id'];
unset($values['id']);
db::update(':table:', $values)->where('id = %i', $id)->execute();
} else {
$sql = 'INSERT INTO [:table:]';
$result = db::query($sql, $values);
}
}
示例7: recursiveLevelUpdate
private function recursiveLevelUpdate($parent_id, $level)
{
static $counter = 0;
$counter++;
$items = db::select('*')->from(':table:')->where('parent = %i', $parent_id)->fetchAll();
foreach ($items as $key => $item) {
$update = $level + $counter;
$values = array('level' => $update);
db::update(':table:', $values)->where('id = %i', $item->id)->execute();
$items[$key]['items'] = $this->recursiveLevelUpdate($item->id, $level);
}
return $items;
}
示例8: save_note
function save_note($id, $title, $body)
{
if ($body == "" && $title == "") {
$title = "Empty note";
}
if (($title == "" || $title == "Empty note") && $body != "") {
$title = truncate(strip_tags($body), 30);
}
$db = new db();
$result = $db->update("notes", array("title" => $title, "body" => $body), "id = :id", array(":id" => $id));
$result = array("id" => $id, "title" => $title, "body" => $body);
return $result;
}
示例9: update
public function update()
{
error_log(__METHOD__);
if (count($_POST)) {
unset($this->in['id'], $this->in['created']);
$this->in['updated'] = date('Y-m-d H:i:s');
db::update($this->in, [['id', '=', $this->g->in['i']]]);
header("Location: ?o=" . $this->o);
exit;
} elseif ($this->g->in['i']) {
return $this->t->{$this->o . '_form'}(array_merge(db::read('*', 'id', $this->g->in['i'], '', 'one'), ['submit' => $this->update]));
} else {
return 'Error with Update';
}
}
示例10: save
public function save($values)
{
$this->_prepare();
$values['email'] = String::lower($values['name'] . '.' . $values['surname'] . '@st.fm.uniba.sk');
if (!isset($values['id'])) {
$values['password'] = String::lower($values['name'] . $values['surname']);
}
if (isset($values['id'])) {
$id = $values['id'];
unset($values['id']);
db::update(':table:', $values)->where('id = %i', $id)->execute();
} else {
$sql = 'INSERT INTO [:table:]';
$result = db::query($sql, $values);
}
}
示例11: restore
function restore()
{
db::table('admin_log_trash');
db::where('log_id', params::get('log_id'));
$date = date('Y-m-d H:i:s');
db::update('log_restored', $date);
db::table('admin_log_trash');
db::where('log_id', params::get('log_id'));
$row = db::assoc();
if ($row['log_tmpl'] == '1') {
trash::restore(params::get('log_id'), SYS_ROOT . 'tmpls/' . ADMIN_SITE . '/');
} else {
trash::restore(params::get('log_id'));
}
buffer::set(dt::date2print('%H:%i:%s<br />%d %F %y', $date));
}
示例12: write
public function write($id, $data)
{
$data = array('session_id' => $id, 'last_activity' => time(), 'data' => base64_encode($data));
if ($this->session_id === NULL) {
// Insert a new session
$query = db::insert($this->table, $data)->execute($this->db);
} elseif ($id === $this->session_id) {
// Do not update the session_id
unset($data['session_id']);
// Update the existing session
$query = db::update($this->table)->set($data)->where('session_id', '=', $id)->execute($this->db);
} else {
// Update the session and id
$query = db::update($this->table)->set($data)->where('session_id', '=', $this->session_id)->execute($this->db);
// Set the new session id
$this->session_id = $id;
}
return (bool) $query->count();
}
示例13: db
<?php
include "../../../../include/classes/main/db.class.php";
$op = $_POST['operation'];
$db = new db();
if ($op == "edit") {
$id = $_POST['id'];
$title = $_POST['title'];
$text = $_POST['text'];
if ($db->update("content", "title='" . $title . "', content='" . $text . "'", " id = '" . $id . "'")) {
echo '0';
} else {
echo '1';
}
} elseif ($op == "add") {
$title = $_POST['title'];
$text = $_POST['text'];
$col[] = "title";
$col[] = "content";
$var[] = $title;
$var[] = $text;
//db::setDebug(2);
if ($db->insert("content", $col, $var)) {
if ($db->insert("navigation_links", array("link", "type", "content_id", "titel", "tpl"), array("content", "1", $db->getLastId(), $title, "1"))) {
echo '0';
}
} else {
echo '1';
}
} elseif ($op == "delete") {
$id = $_POST['id'];
示例14: upgrade
//.........这里部分代码省略.........
if ($version == 18) {
$blocks = block_manager::get_active("site.sidebar");
block_manager::set_active("site_sidebar", $blocks);
module::clear_var("gallery", "blocks_site.sidebar");
module::set_version("gallery", $version = 19);
}
// Set a default for the number of simultaneous uploads
// Version 20 was reverted in 57adefc5baa7a2b0dfcd3e736e80c2fa86d3bfa2, so skip it.
if ($version == 19 || $version == 20) {
module::set_var("gallery", "simultaneous_upload_limit", 5);
module::set_version("gallery", $version = 21);
}
// Update the graphics rules table so that the maximum height for resizes is 640 not 480.
// Fixes ticket #671
if ($version == 21) {
$resize_rule = ORM::factory("graphics_rule")->where("id", "=", "2")->find();
// make sure it hasn't been changed already
$args = unserialize($resize_rule->args);
if ($args["height"] == 480 && $args["width"] == 640) {
$args["height"] = 640;
$resize_rule->args = serialize($args);
$resize_rule->save();
}
module::set_version("gallery", $version = 22);
}
// Update slug values to be legal. We should have done this in the 11->12 upgrader, but I was
// lazy. Mea culpa!
if ($version == 22) {
foreach (db::build()->from("items")->select("id", "slug")->where(db::expr("`slug` REGEXP '[^_A-Za-z0-9-]'"), "=", 1)->execute() as $row) {
$new_slug = item::convert_filename_to_slug($row->slug);
if (empty($new_slug)) {
$new_slug = random::int();
}
db::build()->update("items")->set("slug", $new_slug)->set("relative_url_cache", null)->where("id", "=", $row->id)->execute();
}
module::set_version("gallery", $version = 23);
}
if ($version == 23) {
$db->query("CREATE TABLE {failed_logins} (\n `id` int(9) NOT NULL auto_increment,\n `count` int(9) NOT NULL,\n `name` varchar(255) NOT NULL,\n `time` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;");
module::set_version("gallery", $version = 24);
}
if ($version == 24) {
foreach (array("logs", "tmp", "uploads") as $dir) {
self::_protect_directory(VARPATH . $dir);
}
module::set_version("gallery", $version = 25);
}
if ($version == 25) {
db::build()->update("items")->set("title", db::expr("`name`"))->and_open()->where("title", "IS", null)->or_where("title", "=", "")->close()->execute();
module::set_version("gallery", $version = 26);
}
if ($version == 26) {
if (in_array("failed_logins", Database::instance()->list_tables())) {
$db->query("RENAME TABLE {failed_logins} TO {failed_auths}");
}
module::set_version("gallery", $version = 27);
}
if ($version == 27) {
// Set the admin area timeout to 90 minutes
module::set_var("gallery", "admin_area_timeout", 90 * 60);
module::set_version("gallery", $version = 28);
}
if ($version == 28) {
module::set_var("gallery", "credits", "Powered by <a href=\"%url\">%gallery_version</a>");
module::set_version("gallery", $version = 29);
}
示例15: array
while ($cursor != 0) {
$connection->request('GET', $connection->url('1.1/friends/ids'), array('user_id' => $engagement_user_id, 'cursor' => $cursor));
$http_code = $connection->response['code'];
if ($http_code == 200) {
$data = json_decode($connection->response['response'], true);
// Get the list of friend user_ids, which will be an array
$ids = $data['ids'];
// Get the cursor value for the next request
$cursor = $data['next_cursor_str'];
// If there are any friends returned
if (sizeof($ids)) {
foreach ($ids as $user_id) {
// If this friend is already in the table,
// set the current field back to 1
if ($db->in_table('friends', "user_id={$user_id}")) {
$db->update('friends', 'current=1', "user_id={$user_id}");
} else {
// If this is a new friend,
// insert it with a current value of 1
$db->insert('friends', "user_id={$user_id},current=1");
// If this is not the first time friends have been collected,
// record this new friend event in the follow_log table
if (!$first_collection) {
$db->insert('follow_log', "user_id={$user_id},event='friend'");
}
}
}
} else {
// Stop collecting if no more friends are found
break;
}