本文整理汇总了PHP中Database::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::update方法的具体用法?PHP Database::update怎么用?PHP Database::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initiateTerm
public function initiateTerm($term)
{
$db = new Database();
if ($db->update('judgeInvitations', array('ShowTerm' => $term == '' || $term == null ? 'NA' : 'yes'), "termInitiated = '" . $term . "'")) {
return $db->update('judgeInvitations', array('ShowTerm' => $term == '' || $term == null ? 'NA' : 'no'), "termInitiated != '" . $term . "'");
} else {
return false;
}
}
示例2: add
public function add ($query) {
list($place, $item_id) = $this->parse_referer($query);
if (!empty($query['parent'])) {
$root = Database::get_field('comment', 'root', $query['parent']);
if (empty($root)) {
$root = $query['parent'];
}
} else {
$root = 0;
}
$insert = array(
'root' => $root,
'parent' => $query['parent'],
'place' => $place,
'item_id' => $item_id,
'area' => 'main',
'username' => $query['name'],
'email' => $query['email'],
'ip' => Globals::$user_data['ip'],
'cookie' => Globals::$user_data['cookie'],
'text' => Transform_Text::format($query['text']),
'pretty_text' => $query['text'],
);
Database::insert('comment', $insert);
Database::update($place, $item_id, array('comments' => '++'));
$this->redirect_address = $this->referer;
}
示例3: addNewEquip
function addNewEquip($value)
{
$db = new Database();
$link = $db->connect();
$result = $db->update($link, 'equip_type', array('name' => 2));
return $result;
}
示例4: mergePage
/**
* Merge page histories
*
* @param integer $id The page_id
* @param Title $newTitle The new title
* @return bool
*/
private function mergePage($row, Title $newTitle)
{
$id = $row->page_id;
// Construct the WikiPage object we will need later, while the
// page_id still exists. Note that this cannot use makeTitleSafe(),
// we are deliberately constructing an invalid title.
$sourceTitle = Title::makeTitle($row->page_namespace, $row->page_title);
$sourceTitle->resetArticleID($id);
$wikiPage = new WikiPage($sourceTitle);
$wikiPage->loadPageData('fromdbmaster');
$destId = $newTitle->getArticleID();
$this->beginTransaction($this->db, __METHOD__);
$this->db->update('revision', ['rev_page' => $destId], ['rev_page' => $id], __METHOD__);
$this->db->delete('page', ['page_id' => $id], __METHOD__);
$this->commitTransaction($this->db, __METHOD__);
/* Call LinksDeletionUpdate to delete outgoing links from the old title,
* and update category counts.
*
* Calling external code with a fake broken Title is a fairly dubious
* idea. It's necessary because it's quite a lot of code to duplicate,
* but that also makes it fragile since it would be easy for someone to
* accidentally introduce an assumption of title validity to the code we
* are calling.
*/
DeferredUpdates::addUpdate(new LinksDeletionUpdate($wikiPage));
DeferredUpdates::doUpdates();
return true;
}
示例5: isAuthenticated
public static function isAuthenticated()
{
//TODO
//look if Token is present in $_Session
Session::get('UserID') ? $auth = 'TRUE' : ($auth = 'FALSE');
if ($auth === 'TRUE') {
return TRUE;
} else {
if (isset($_COOKIE["RemembeR"])) {
$db = new Database();
//Get TOKEN from $_COOKIE
//hash(Token) and compare with hashed Tokens in the Database
$userdata['tokenhash'] = hash('sha1', $_COOKIE["RemembeR"]);
echo $userdata['tokenhash'];
$arr = $db->select("SELECT id, tokenhash FROM users WHERE tokenhash = :tokenhash LIMIT 1", $userdata);
var_dump($arr);
if (sizeof($arr[0]['id']) !== 0) {
//Set 'UserID' in Session
Session::set('UserID', $arr[0]['id']);
//Renew Cookie
$token = hash("md5", $arr[0]['id'] . Session::get('ID'));
$userdata['id'] = $arr[0]['id'];
$userdata['tokenhash'] = hash("sha1", $token);
$db->update("users", $userdata, "id = :id");
setcookie("RemembeR", $token, time() + 259200, "/", "studi.f4.htw-berlin.de", false, true);
return TRUE;
}
}
}
return FALSE;
}
示例6: convertOptionBatch
/**
* @param ResultWrapper $res
* @param Database $dbw
* @return null|int
*/
function convertOptionBatch($res, $dbw)
{
$id = null;
foreach ($res as $row) {
$this->mConversionCount++;
$insertRows = [];
foreach (explode("\n", $row->user_options) as $s) {
$m = [];
if (!preg_match("/^(.[^=]*)=(.*)\$/", $s, $m)) {
continue;
}
// MW < 1.16 would save even default values. Filter them out
// here (as in User) to avoid adding many unnecessary rows.
$defaultOption = User::getDefaultOption($m[1]);
if (is_null($defaultOption) || $m[2] != $defaultOption) {
$insertRows[] = ['up_user' => $row->user_id, 'up_property' => $m[1], 'up_value' => $m[2]];
}
}
if (count($insertRows)) {
$dbw->insert('user_properties', $insertRows, __METHOD__, ['IGNORE']);
}
$dbw->update('user', ['user_options' => ''], ['user_id' => $row->user_id], __METHOD__);
$id = $row->user_id;
}
return $id;
}
示例7: process
public function process()
{
$tag = $this->get('tag');
$type = $this->get('type');
if (empty($tag)) {
throw new Error_Api('Пропущено обязательное поле: tag', Error_Api::MISSING_INPUT);
}
if (empty($type)) {
throw new Error_Api('Пропущено обязательное поле: type', Error_Api::MISSING_INPUT);
}
if (!array_key_exists($type, $this->types)) {
throw new Error_Api('Неправильно заполнено поле: type', Error_Api::INCORRECT_INPUT);
}
$color = $this->types[$type];
$tag = trim(undo_safety($tag));
$args = array($tag, '|' . $tag . '|', $tag);
$exists = Database::get_field('tag', 'alias', 'name = ? or locate(?, variants) or alias = ?', $args);
if ($exists) {
$alias = $exists;
} else {
$alias = Transform_Meta::make_alias($tag);
Database::insert('tag', array('alias' => $alias, 'name' => $tag, 'variants' => '|'));
$this->add_error(Error_Api::UNKNOWN_TAG);
}
Database::update('tag', array('color' => $color), 'alias = ?', $alias);
$this->set_success(true);
$this->add_answer('tag', $alias);
}
示例8: save
public function save()
{
if (!$this->tableName || !$this->databaseFields) {
return;
}
$invalid = false;
$values = array();
foreach ($this->databaseFields as $fieldName) {
if (isset($this->{$fieldName})) {
if (is_object($this->{$fieldName})) {
$values[$fieldName] = $this->{$fieldName}->id;
} else {
$values[$fieldName] = $this->{$fieldName};
}
}
}
if (!$invalid) {
if ($this->id == null) {
$this->id = Database::insert($this->tableName, $values);
} else {
Database::update($this->tableName, $this->id, $values);
}
$this->saved = true;
}
}
示例9: test_links
protected function test_links($links)
{
$this->worker->enable_limit(self::MAX_DOWNLOAD_SIZE)->add($links)->exec();
foreach ($links as $id => $link) {
$status = $this->test_result($link);
if ($status === false) {
continue;
}
Database::update('post_url', array('status' => $status, 'lastcheck' => Database::unix_to_date()), $id);
if ($status == self::STATUS_UNKNOWN) {
$this->create_unknown_file($link);
}
}
$this->worker->flush();
$keys = array_keys($links);
$post_ids = Database::join('post_link_url', 'plu.link_id = pl.id')->join('post_url', 'plu.url_id = pu.id')->get_vector('post_link', 'post_id', Database::array_in('pu.id', $keys), $keys);
$post_ids = array_unique($post_ids);
foreach ($post_ids as $post_id) {
$status = new Model_Post_Status($post_id);
$status->load()->calculate()->commit();
}
$update_ids = Database::join('post_update_link_url', 'pulu.link_id = pul.id')->join('post_url', 'pulu.url_id = pu.id')->get_vector('post_update_link', 'update_id', Database::array_in('pu.id', $keys), $keys);
$update_ids = array_unique($update_ids);
foreach ($update_ids as $update_id) {
$status = new Model_Post_Update_Status($update_id);
$status->load()->calculate()->commit();
}
}
示例10: update
function update($criteria, $new_object, $options = [])
{
if (!isset($new_object['rmts']) && !isset($new_object['upts'])) {
$new_object['upts'] = $_SERVER['REQUEST_TIME'];
}
return parent::update($criteria, $new_object, $options);
}
示例11: editEquip
function editEquip($value, $id)
{
$db = new Database();
$link = $db->connect();
$result = $db->update($link, 'equip_type', array('name' => $value), 'type_id=' . $id);
return $result;
}
示例12: init
public function init($database, $dbName, $public, $version)
{
# Check dependencies
self::dependencies(isset($this->settings, $public, $version));
# Call plugins
$this->plugins(__METHOD__, 0, func_get_args());
# Update
if (!isset($this->settings['version']) || $this->settings['version'] !== $version) {
if (!Database::update($database, $dbName, @$this->settings['version'])) {
Log::error($database, __METHOD__, __LINE__, 'Updating the database failed');
exit('Error: Updating the database failed!');
}
}
# Clear expired sessions
$query = Database::prepare($this->database, "DELETE FROM ? WHERE expires < UNIX_TIMESTAMP(NOW())", array(LYCHEE_TABLE_SESSIONS));
$this->database->query($query);
# Return settings
$return['config'] = $this->settings;
# Remove username and password from response
unset($return['config']['username']);
unset($return['config']['password']);
# Remove identifier from response
unset($return['config']['identifier']);
# Path to Lychee for the server-import dialog
$return['config']['location'] = LYCHEE;
# Check if login credentials exist and login if they don't
if ($this->noLogin() === true) {
$public = false;
$return['config']['login'] = false;
} else {
$return['config']['login'] = true;
}
# Check login with crypted hash
if (isset($_COOKIE['SESSION']) && $this->sessionExists($_COOKIE['SESSION'])) {
$_SESSION['login'] = true;
$_SESSION['identifier'] = $this->settings['identifier'];
$public = false;
}
if ($public === false) {
# Logged in
$return['status'] = LYCHEE_STATUS_LOGGEDIN;
} else {
# Logged out
$return['status'] = LYCHEE_STATUS_LOGGEDOUT;
# Unset unused vars
unset($return['config']['thumbQuality']);
unset($return['config']['sortingAlbums']);
unset($return['config']['sortingPhotos']);
unset($return['config']['dropboxKey']);
unset($return['config']['login']);
unset($return['config']['location']);
unset($return['config']['imagick']);
unset($return['config']['medium']);
unset($return['config']['plugins']);
}
# Call plugins
$this->plugins(__METHOD__, 1, func_get_args());
return $return;
}
示例13: processUpdates
/**
* Package metadata updates.
*
* @param Database $db
* @param array $updates
* @return bool
* @throws TypeError
*/
function processUpdates(Database $db, array $updates = []) : bool
{
$db->beginTransaction();
foreach ($updates as $update) {
$db->update('airship_package_cache', ['skyport_metadata' => \json_encode($update['metadata'])], ['packagetype' => $update['package']['type'], 'supplier' => $update['package']['supplier'], 'name' => $update['package']['name']]);
}
return $db->commit();
}
示例14: fin_notificaciones
public static function fin_notificaciones()
{
///$configdb = new Mysql('localhost','root','','corsione');
$configdb = new Database();
$configdb->connect();
$configdb->update('notificaciones', array('estado' => "1"), 'estado="0"');
$res = $configdb->getResult();
}
示例15: update_lifetime
protected function update_lifetime()
{
$domain = preg_replace('/^[^\.]+/ui', '', $_SERVER['SERVER_NAME']);
setcookie($this->name, $this->hash, time()+3600*24*60, '/', $domain);
// Фиксируем факт обновления в БД
Database::update('cookie', ['lastchange' => time()],
'cookie = ?', $this->hash);
}