本文整理汇总了PHP中DBLayer::update方法的典型用法代码示例。如果您正苦于以下问题:PHP DBLayer::update方法的具体用法?PHP DBLayer::update怎么用?PHP DBLayer::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBLayer
的用法示例。
在下文中一共展示了DBLayer::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deactivate_plugin
/**
* This function is used in deactivating plugins.
* This can be done by providing id using $_GET global variable of the plugin which
* we want to activate. After getting id we update the respective plugin with status
* deactivate which here means '0'.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function deactivate_plugin()
{
// if logged in
if (WebUsers::isLoggedIn()) {
if (isset($_GET['id'])) {
// id of plugin to deactivate
$id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$db = new DBLayer('lib');
$result = $db->update("plugins", array('Status' => '0'), "Id = {$id}");
if ($result) {
// if result is successfull it redirects and shows success message
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=5");
throw new SystemExit();
} else {
// if result is unsuccessfull it redirects and shows success message
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=6");
throw new SystemExit();
}
} else {
//if $_GET variable is not set it redirects and shows error
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=6");
throw new SystemExit();
}
}
}
示例2: userRegistration
/**
* This function is beign used to change the users emailaddress info.
* It will first check if the user who executed this function is the person of whom the emailaddress is or if it's a mod/admin. If this is not the case the page will be redirected to an error page.
* The emailaddress will be validated first. If the checking was successful the email will be updated and the settings template will be reloaded. Errors made by invalid data will be shown
* also after reloading the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function userRegistration()
{
try {
//if logged in
if (WebUsers::isLoggedIn()) {
$dbl = new DBLayer("lib");
$dbl->update("settings", array('Value' => $_POST['userRegistration']), "`Setting` = 'userRegistration'");
$result['target_id'] = $_GET['id'];
global $SITEBASE;
require_once $SITEBASE . '/inc/settings.php';
$pageElements = settings();
$pageElements = array_merge(settings(), $result);
$pageElements['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
// pass error and reload template accordingly
helpers::loadtemplate('settings', $pageElements);
throw new SystemExit();
} else {
//ERROR: user is not logged in
header("Location: index.php");
throw new SystemExit();
}
} catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
throw new SystemExit();
}
}
示例3: domain_management_hook_get_db
/**
* Global Hook to return global variables which contains
* the content to use in the smarty templates extracted from
* the database
*
* @return $domain_management_return_set global array returns the template data
*/
function domain_management_hook_get_db()
{
global $domain_management_return_set;
if (isset($_GET['ModifyDomain']) && ($_GET['ModifyDomain'] = '1' && isset($_POST['domain_name']))) {
try {
$dbs = new DBLayer('shard');
$dbs->update("domain", array('domain_name' => $_POST['domain_name'], 'status' => $_POST['status'], 'patch_version' => $_POST['patch_version'], 'backup_patch_url' => $_POST['backup_patch_url'], 'patch_urls' => $_POST['patch_urls'], 'login_address' => $_POST['login_address'], 'session_manager_address' => $_POST['session_manager_address'], 'ring_db_name' => $_POST['ring_db_name'], 'web_host' => $_POST['web_host'], 'web_host_php' => $_POST['web_host_php'], 'description' => $_POST['description']), '`domain_id` = ' . $_GET['edit_domain']);
} catch (Exception $e) {
return null;
}
}
if (isset($_GET['ModifyPermission']) && ($_GET['ModifyPermission'] = '1' && isset($_POST['user']))) {
try {
$dbl = new DBLayer("lib");
$statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", array('setting' => 'Domain_Auto_Add'));
$json = $statement->fetch();
$json = json_decode($json['Value'], true);
$json[$_GET['edit_domain']]['1'] = $_POST['user'];
$json[$_GET['edit_domain']]['2'] = $_POST['moderator'];
$json[$_GET['edit_domain']]['3'] = $_POST['admin'];
$update = json_encode($json);
$dbl->update("settings", array('Value' => $update), "`Setting` = 'Domain_Auto_Add'");
} catch (Exception $e) {
return null;
}
}
try {
$db = new DBLayer('shard');
// get all domains
$statement = $db->executeWithoutParams("SELECT * FROM domain");
$rows = $statement->fetchAll();
$domain_management_return_set['domains'] = $rows;
if (isset($_GET['edit_domain'])) {
// get permissions
$statement = $db->executeWithoutParams("SELECT * FROM `domain` WHERE `domain_id` = '" . $_GET['edit_domain'] . "'");
$rows = $statement->fetchAll();
$domain_management_return_set['domains'] = $rows;
$statement = $db->executeWithoutParams("SELECT * FROM `permission` WHERE `DomainId` = '" . $_GET['edit_domain'] . "'");
$rows = $statement->fetchAll();
$domain_management_return_set['permissions'] = $rows;
// get all users
$pagination = new Pagination(WebUsers::getAllUsersQuery(), "web", 10, "WebUsers");
$domain_management_return_set['userlist'] = Gui_Elements::make_table($pagination->getElements(), array("getUId", "getUsername", "getEmail"), array("id", "username", "email"));
$dbl = new DBLayer("lib");
$statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", array('setting' => 'Domain_Auto_Add'));
$json = $statement->fetch();
$json = json_decode($json['Value'], true);
$domain_management_return_set['Domain_Auto_Add'] = $json[$_GET['edit_domain']];
}
return $rows;
} catch (Exception $e) {
return null;
}
}
示例4: update_plugin
/**
* This function is used in installing updates for plugins.
* It takes id of the plugin whose update is available using
* $_GET global variable and then extract the update details
* from db and then install it in the plugin.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function update_plugin()
{
// if logged in
if (WebUsers::isLoggedIn()) {
if (isset($_GET['id'])) {
// id of plugin to update
$id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$db = new DBLayer('lib');
$sth = $db->executeWithoutParams("SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id={$id}");
$row = $sth->fetch();
// replacing update in the database
Plugincache::rrmdir($row['FileName']);
Plugincache::zipExtraction($row['UpdatePath'], rtrim($row['FileName'], strtolower($row['Name'])));
$db->update("plugins", array('Info' => $row['UpdateInfo']), "Id={$row['Id']}");
// deleting the previous update
$db->delete("updates", array('id' => $row['s.no']), "s.no=:id");
// if update is installed succesffully redirect to show success message
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=8");
throw new SystemExit();
}
}
}
示例5: update
/**
* updates the entry.
*/
public function update()
{
$dbl = new DBLayer("lib");
$dbl->update("ams_querycache", array('type' => $this->getType(), 'query' => $this->getQuery(), 'db' => $this->getDb(), "SID={$this->getSID}()"));
}
示例6: update
/**
* update the objects attributes to the db.
*/
public function update()
{
$dbl = new DBLayer("lib");
$dbl->update("ticket", array('Timestamp' => $this->timestamp, 'Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority), "TId={$this->tId}");
}
示例7: setAmsEmail
/**
* sets the shards email.
* in case the shard is offline, the entry will be stored in the ams_querycache.
* @param $user the usersname of the account of which we want to change the emailaddress.
* @param $mail the new email address
* @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline.
*/
protected static function setAmsEmail($user, $mail)
{
$values = array('Email' => $mail);
try {
//make connection with and put into shard db
$dbs = new DBLayer("shard");
$dbs->update("user", $values, "Login = '{$user}'");
return "ok";
} catch (PDOException $e) {
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
try {
error_log($e);
$dbl = new DBLayer("lib");
$dbl->insert("ams_querycache", array("type" => "change_mail", "query" => json_encode(array($user, $mail)), "db" => "shard"));
return "shardoffline";
} catch (PDOException $e) {
return "liboffline";
}
}
}
示例8: update
/**
* update the object's attributes to the database.
*/
public function update()
{
$dbl = new DBLayer("lib");
$dbl->update("ticket_content", array('Content' => $this->content), "TContentId = {$this->tContentId}");
}
示例9: syncdata
/**
* performs the actions listed in the querycache.
* All entries in the querycache will be read and performed depending on their type.
* This is done because the shard could have been offline and we want changes made on the website (which is still online) to eventually hit the shard.
* These changes are: createPermissions, createUser, change_pass, change_mail
*/
public static function syncdata($display = false)
{
if (function_exists('pcntl_fork')) {
$pid = pcntl_fork();
}
global $AMS_TMPDIR;
$pidfile = $AMS_TMPDIR . '/ams_cron_pid';
if (isset($pid) and function_exists('pcntl_fork')) {
// We're the main process.
} else {
$pid = getmypid();
if (Sync::check_for_pid(@file_get_contents($pidfile))) {
$file = fopen($pidfile, 'w+');
if (!$file) {
echo $pidfile . ' is not writeable.';
error_log($pidfile . ' is not writeable.');
throw new SystemExit();
}
fwrite($file, $pid);
fclose($file);
try {
$dbl = new DBLayer("lib");
$statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache");
$rows = $statement->fetchAll();
foreach ($rows as $record) {
$db = new DBLayer($record['db']);
switch ($record['type']) {
case 'createPermissions':
$decode = json_decode($record['query']);
$values = array('username' => $decode[0]);
//make connection with and put into shard db & delete from the lib
$sth = $db->selectWithParameter("UId", "user", $values, "Login= :username");
$result = $sth->fetchAll();
/*foreach ($result as $UId) {
$ins_values = array('UId' => $UId['UId']);
$ins_values['ClientApplication'] = "r2";
$ins_values['AccessPrivilege'] = "OPEN";
$db->insert("permission", $ins_values);
$ins_values['ClientApplication'] = 'ryzom_open';
$db->insert("permission",$ins_values);
}*/
// FIXME: GARBAGE
break;
case 'change_pass':
$decode = json_decode($record['query']);
$values = array('Password' => $decode[1]);
//make connection with and put into shard db & delete from the lib
$db->update("user", $values, "Login = '{$decode['0']}'");
break;
case 'change_mail':
$decode = json_decode($record['query']);
$values = array('Email' => $decode[1]);
//make connection with and put into shard db & delete from the lib
$db->update("user", $values, "Login = '{$decode['0']}'");
break;
case 'createUser':
$decode = json_decode($record['query']);
$values = array('Login' => $decode[0], 'Password' => $decode[1], 'Email' => $decode[2]);
//make connection with and put into shard db & delete from the lib
$db->insert("user", $values);
break;
}
$dbl->delete("ams_querycache", array('SID' => $record['SID']), "SID=:SID");
}
if ($display == true) {
print 'Syncing completed';
}
} catch (PDOException $e) {
if ($display == true) {
print 'Something went wrong! The shard is probably still offline!';
print_r($e);
}
}
unlink($pidfile);
}
}
}
示例10: update
/**
* update object attributes to the DB.
*/
public function update()
{
$dbl = new DBLayer("lib");
$dbl->update("ticket_category", array('Name' => $this->name), "TCategoryId = {$this->tCategoryId}");
}
示例11: update
/**
* update the objects attributes to the db.
*/
public function update()
{
$dbl = new DBLayer("lib");
$dbl->update("`support_group`", array('Name' => $this->getName(), 'Tag' => $this->getTag(), 'GroupEmail' => $this->getGroupEmail(), 'IMAP_MailServer' => $this->getIMAP_MailServer(), 'IMAP_Username' => $this->getIMAP_Username(), 'IMAP_password' => $this->getIMAP_Password()), "`SGroupId` = " . $this->getSGroupId());
}
示例12: update
/**
* update attributes of the object to the DB.
*/
public function update()
{
$dbl = new DBLayer("lib");
$values = array('timestamp' => $this->getTimestamp(), 'query' => $this->getQuery(), 'author' => $this->getAuthor(), 'ticket' => $this->getTicket());
$dbl->update("ticket_log", $values, "TLogId = {$this->getTLogId}()");
}
示例13: update
/**
* updates a ticket_reply entry based on the objects attributes.
*/
public function update()
{
$dbl = new DBLayer("lib");
$dbl->update("ticket", array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author, 'Timestamp' => $this->timestamp, 'Hidden' => $this->hidden), "TReplyId={$this->tReplyId}, ");
}
示例14: update
/**
* update the object's attributes to the db.
*/
public function update()
{
$dbl = new DBLayer("lib");
$dbl->update("ticket_user", array('Permission' => $this->permission, 'ExternId' => $this->externId), "TUserId={$this->tUserId}");
}
示例15: setLanguage
/**
* update the language value in the db.
* update the language in the www/CMS version.
* @param $user the username
* @param $language the new language value.
*/
public static function setLanguage($user, $language)
{
$values = array('Language' => $language);
try {
//make connection with and put into shard db
$dbw = new DBLayer("web");
$dbw->update("ams_user", $values, "UId = {$user}");
} catch (PDOException $e) {
//ERROR: the web DB is offline
}
}