本文整理汇总了PHP中db::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP db::execute方法的具体用法?PHP db::execute怎么用?PHP db::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db
的用法示例。
在下文中一共展示了db::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
public function __set($name, $value)
{
$s_name = db::escape($name);
$s_val = db::escape($value);
$s_uid = db::escape($this->_uid);
return db::execute("REPLACE INTO 202_config (var_name, var_value, user_id)\n VALUES ('{$s_name}', '{$s_val}', '{$s_uid}')");
}
示例2: saveRule
public function saveRule($rule_id, $start_ip, $end_ip, $rule_state)
{
$sql = "UPDATE\n firewall_rules\n SET\n start_ip='" . db::escapechars($start_ip) . "',\n end_ip='" . db::escapechars($end_ip) . "',\n rule_state='" . db::escapechars($rule_state) . "'\n date_modified=NOW()\n WHERE\n rule_id='" . db::escapechars($rule_id) . "'\n LIMIT 1";
$updateFirewall = db::execute($sql);
if ($removeItem) {
// Log activity
$logType = "Firewall";
$logValue = db::escapechars($_SESSION['username']) . " updated a firewall rule - " . db::escapechars($ruleid);
$this->logevent($logType, $logValue);
return true;
} else {
// Log failure
$logValue = db::escapechars($_SESSION['username']) . " Failed updating a firewall rule - " . db::escapechars($sql);
$this->logfault($logValue);
return false;
}
}
示例3: storeAppSettings
public function storeAppSettings($settingName, $settingValue)
{
$errors = 0;
// For each of the provided settings store the associated value
for ($i = 0; $i <= count($settingName); $i++) {
$sql = "UPDATE\n framework_settings\n SET\n settingValue='" . db::escapechars($settingValue[$i]) . "'\n WHERE\n settingName='" . db::escapechars($settingName[$i]) . "'\n LIMIT 1";
$result = db::execute($sql);
if ($result) {
$this->logevent('Settings Update', $_SESSION['username'] . " updated setting " . db::escapechars($settingName[$i]) . " to " . db::escapechars($settingValue[$i]));
} else {
$errors++;
$this->logerror("Error updating settings: " . $sql);
}
}
if ($errors > 0) {
return false;
} else {
return true;
}
}
示例4: run
function run($query, $param, $action = '', $db = null)
{
$response = false;
$db = new db(null, $db);
$db->query($query);
$db->execute($param);
switch ($action) {
case 'fetch':
$response = $db->fetch();
break;
case 'update':
$response = $db;
break;
case 'insert':
$response = $db->lastInsertId();
break;
default:
$response = $db->fetchset();
break;
}
return $response;
}
示例5: importUser
public static function importUser($affiliate_id, $install_db)
{
// Grab user from directtrack db.
//$s_addcode = db::escape($pub);
$user = db::getRow("select * from prosper_master.affiliates WHERE affiliate_id='{$affiliate_id}'");
//md5 the user pass with salt
$user_pass = salt_user_pass($_SESSION['login_pass']);
$mysql['user_pass'] = db::escape($user_pass);
//insert this user
$user_sql = " \tINSERT INTO {$install_db}.`202_users`\n\t\t\t\t\t \tSET\tuser_email='" . $user['email'] . "',\n\t\t\t\t\t \t\tuser_name='" . $user['addCode'] . "',\n\t\t\t\t\t \t\tuser_pass='" . $mysql['user_pass'] . "',\n\t\t\t\t\t \t\taddCode='" . $user['addCode'] . "',\n\t\t\t\t\t \t\tuser_timezone='-5',\n\t\t\t\t\t \t\tuser_time_register=NOW()";
//die($user_sql);
$user_result = db::execute($user_sql);
$user_id = mysql_insert_id(db::$db_write);
$mysql['user_id'] = db::escape($user_id);
$mysql['affiliate_id'] = $user['affiliate_id'];
$md5token = md5(serialize($user) . uniqid());
$_SESSION['authtoken'] = $md5token;
db::execute("insert into prosper_master.login_tokens(affiliate_id, user_id, user_name, token)\n\t\t values ('" . $mysql['affiliate_id'] . "', '" . $mysql['user_id'] . "', '" . $user['addCode'] . "', '" . $md5token . "');");
//update user preference table
$user_sql = "INSERT INTO {$install_db}.`202_users_pref` SET user_id='" . $mysql['user_id'] . "'";
$user_result = db::execute($user_sql);
}
示例6: getAverages
function getAverages($company_id)
{
$scores = [];
$superaverage = 0;
//create keys for scores and zero out any leftover data in the scores array
$keys = ['company_id', 'WLBalance', 'Salary', 'Benefits', 'Opportunity', 'Fairness', 'Leadership', 'Loyalty', 'Morale', 'Communication'];
foreach ($keys as $key) {
$scores[$key] = 0;
}
//now I know I could replace all of this with a simple SQL query
// $db = new DB;
$sql = "SELECT * FROM Reviews WHERE company_id = {$company_id}";
$results = db::execute($sql);
// $results = $db->execute($sql);
//grab number of reviews for calculating average
$count = $results->num_rows;
//remove non-calculation columns and sum the rest into the scores array
while ($row = $results->fetch_assoc()) {
unset($row['review_id']);
unset($row['person_id']);
unset($row['ReviewText']);
foreach ($row as $key => $value) {
$scores[$key] += $value;
}
}
//calculate average for each column and trim to two decimal places
foreach ($scores as $key => $value) {
$scores[$key] = substr($value / $count, 0, 4);
}
//sum the averages and get that average and add to the array
foreach ($scores as $key => $value) {
$superaverage += $value;
}
$superaverage /= count($keys);
$superaverage = substr($superaverage, 0, 4);
$scores['Average'] = $superaverage;
return $scores;
}
示例7: resetPassword
public function resetPassword($userid, $seededpassword, $newpasswd = '')
{
$userid = db::escapechars($userid);
$newpasswd = db::escapechars($newpasswd);
if (is_null($newpasswd)) {
$newpassword = $this->generatePassword();
} else {
$newpassword = $newpasswd;
}
$newpasswordmd5 = md5($newpassword . $seededpassword);
$sql = "UPDATE\n users\n SET\n password='{$newpasswordmd5}'\n WHERE\n userid='{$userid}'\n LIMIT 1";
$resetpass = db::execute($sql);
if ($resetpass) {
// Log the activity
$logType = "Reset Password";
$IPAddress = $_SERVER["REMOTE_ADDR"];
$myusername = $_SESSION['username'];
$theirusername = $this->useridtoname($userid);
$logValue = "{$myusername} reset user password for user ( {$theirusername} )";
$this->logevent($logType, $logValue);
// Email user with reset notification
$message = "<h2>Password Reset</h2><p>Hello, a reset password request was sent for your account ({$theirusername}).</p><p>Your new password is {$newpassword}</p><p>You should log on and change this as soon as possible</p>";
$this->emailUser($userid, 'Password Reset', $message);
return true;
} else {
return false;
}
}
示例8: logged_in
public static function logged_in()
{
$session_time_passed = time() - $_SESSION['session_time'];
// Tricky logic for handing off authentication across subdomains.
if (!isset($_SESSION['user_id']) && !isset($_SESSION['login_user']) && isset($_GET['auth'])) {
$s_token = db::escape($_GET['auth']);
$user_row = db::getRow("SELECT lt.*, a.addCode from prosper_master.login_tokens lt\r\n INNER JOIN prosper_master.affiliates a ON lt.affiliate_id=a.affiliate_id\r\n WHERE token='{$s_token}'");
$_SESSION['session_fingerprint'] = md5('session_fingerprint' . $_SERVER['HTTP_USER_AGENT'] . session_id());
$_SESSION['session_time'] = time();
$_SESSION['user_name'] = $user_row['user_name'];
$_SESSION['user_id'] = $user_row['user_id'];
$_SESSION['addCode'] = $user_row['addCode'];
$_SESSION['user_api_key'] = @$user_row['user_api_key'];
$_SESSION['user_stats202_app_key'] = @$user_row['user_stats202_app_key'];
$_SESSION['user_timezone'] = @$user_row['user_timezone'];
@db::execute("delete from prosper_master.login_tokens WHERE token='{$s_token}' LIMIT 1");
$uri = preg_replace('/auth=[a-zA-Z0-9]+/', '', $_SERVER['REQUEST_URI']);
forward($uri);
exit;
}
if (!isset($_SESSION['user_id']) && isset($_SESSION['login_user'])) {
if (self::login($_SESSION['login_user'], $_SESSION['login_pass'])) {
return true;
}
}
if ($_SESSION['user_name'] and $_SESSION['user_id'] and $_SESSION['session_fingerprint'] == md5('session_fingerprint' . $_SERVER['HTTP_USER_AGENT'] . session_id()) and $session_time_passed < 50000) {
$_SESSION['session_time'] = time();
return true;
} else {
return false;
}
}
示例9: purgeDiary
public function purgeDiary($classid, $teacherid)
{
// Check if owner of the class or if an administrator
$classInfo = $this->getClassInformation($classid);
if ($classInfo['teacher_id'] == $teacherid || $_SESSION['utype'] >= 8) {
$sql = "DELETE FROM\n class_diary\n WHERE\n class_id='" . db::escapechars($classid) . "'\n AND\n item_status='9'";
$purge = db::execute($sql);
if ($purge) {
// Log the activity
$logType = "Classes";
$logValue = db::escapechars($_SESSION['username']) . " Purged class diary events - " . db::escapechars($classid);
$this->logevent($logType, $logValue);
return true;
} else {
// Log the activity
$logValue = db::escapechars($_SESSION['username']) . " Failed Purging class diary events - " . db::escapechars($sql);
$this->logfault($logValue);
return false;
}
} else {
return false;
}
}
示例10: delete
public static function delete($where = array())
{
$sql = "DELETE FROM %s%s;";
$sql = sprintf($sql, self::filter_table(self::$settings['table']), self::where_str($where));
debug::set('sql', self::$settings['class'] . '::' . __FUNCTION__, $sql);
return parent::execute($sql) ? 1 : 0;
return -1;
}
示例11: db
<?php
include_once BASE_PATH . 'admin/utils/initialize.php';
if (!empty($_POST)) {
$db = new db();
$country_id = $db->escape_string($_POST['country_id']);
$rss = $db->escape_string($_POST['rss']);
$sql = $db->execute("INSERT INTO rss (country_id, link, active) VALUES ('{$country_id}', '{$rss}', '1')");
}
echo $twig->render('add_rss.html', array('active_menu' => 'add_rss', 'msg' => $msg, 'title_part' => 'Adăugare rss', 'utils' => $utils, 'slugs' => get_slugs()));
示例12: foreach
$country_slug = $slug['slug'];
$rsss = $db->array_select("SELECT * FROM rss WHERE country_id = '{$country_id}' AND active='1'");
foreach ($rsss as $rss) {
$content = file_get_contents($rss['link']);
$xmlfeed = new SimpleXmlElement($content);
$author = $xmlfeed->channel->link;
$first = strpos($author, '.');
$author = substr($author, $first + 1);
$second = strpos($author, '/');
$author = substr($author, 0, $second);
foreach ($xmlfeed->channel->item as $entry) {
if (strpos($entry->pubDate, $today)) {
$title = $db->escape_string($entry->title);
$double = $db->num_rows("SELECT id FROM news WHERE title = '{$title}'");
if ($double == 0) {
$link = $db->escape_string($entry->link);
$pubDate = $entry->pubDate;
$date = convert_date($pubDate);
$description = prepare_description($entry->description);
$site_link = prepare_link($title, $country_slug);
$metakeywords = prepare_metakeywords($description);
$metadescription = prepare_metadescription($description);
$sql = $db->execute("INSERT INTO news (country_id, author, title, description, site_link, link, pubdate, metadescription, metakeywords) VALUES ('{$country_id}', '{$author}', '{$title}', '{$description}', '{$site_link}','{$link}', '{$date}', '{$metadescription}', '{$metakeywords}')");
}
}
}
}
}
}
//delete entries older than 2 days
$sql = $db->execute("DELETE from news WHERE (pubdate NOT LIKE '%{$today2}%' AND pubdate NOT LIKE '%{$yesterday}%' AND pubdate NOT LIKE '%{$yesterday2}%')");
示例13: die
defined('WCROOT') or die('Access Denied');
require WCROOT . PS . "config" . PS . "config_" . $_SESSION['domain'] . ".php";
$db = new db();
$sqlfile = WCROOT . '/install/data/basic.sql';
file_exists($sqlfile) or die('<br /><font color="#F00">数据库安装文件丢失:' . $sqlfile . '</font>');
$sql = file_get_contents($sqlfile);
$sql = str_replace("\r\n", "\n", $sql);
if (empty($sql)) {
die('无法获取安装数据。file_get_contents()');
}
$sql = trim(str_replace("\r", "\n", str_replace(' `ws_', ' `' . $db_config['db_pre'], $sql)));
$ret = explode(";\n", $sql);
unset($sql);
$result = true;
foreach ($ret as $sql) {
$sql = trim($sql);
@$db->execute($sql) or $result = false;
}
if ($result) {
msgbox('', 'index.php?step=6');
} else {
echo '<div style="padding:30px 0 30px 20px; color:#F00;">系统模块安装失败,请重新安装或尝试跳过这一步。</div>';
}
?>
<table width="100%"><tr>
<td width="80" height="80"> </td>
<td align="center"><a href="index.php?step=4" onfocus="this.blur()"><img src="images/button_prev.png" width="112" height="35" /></a></td>
<td align="center"><a href="index.php?step=6" onfocus="this.blur()"><img src="images/button_next.png" width="112" height="35" /></a></td>
<td width="80"> </td>
</tr></table>
示例14: IFNULL
$db->beginTransaction();
if ($attach_id == 'e') {
$db->query("SELECT IFNULL(MAX(attach_group_id),0) + 1 as max_id FROM attachments");
$res = $db->fetch();
if (!empty($res)) {
$new_attach_id = $res['max_id'];
} else {
$new_attach_id = 1;
}
} else {
$new_attach_id = $attach_id;
}
$db->query("INSERT INTO attachments (attach_group_id, attach_desc)\n\t\t\t\tVALUES (:attach_group_id, :attach_desc)");
$db->bind(":attach_group_id", $new_attach_id);
$db->bind(":attach_desc", $file_name);
$sq = $db->execute();
$db->endTransaction();
$flag = 1;
} catch (Exception $e) {
$flag = 2;
$db->cancelTransaction();
}
} else {
$flag = 3;
}
}
$db->query("SELECT * FROM attachments WHERE attach_group_id = :id");
$db->bind(":id", $new_attach_id);
$getAttaches = $db->fetchAll();
if (!empty($getAttaches)) {
foreach ($getAttaches as $row) {
示例15: create
/**
* build the create table query
*/
private static function create($tableDef = array())
{
try {
$table = $tableDef['table'];
$cols = $tableDef['columns'];
$query = "create table " . $table['name'] . " (";
foreach ($cols as $col => $def) {
$query .= $col . " " . $def['type'] . " (" . $def['length'] . ") ,";
}
$query = rtrim($query, ",");
$query .= ")";
if ($table['charset'] && $table['collate']) {
$query .= "CHARACTER SET " . $table['charset'] . " COLLATE " . $table['collate'];
}
$db = new db();
echo $db->execute($query) ? "DB table " . $tableDef['table']['name'] . " migrated" : "Some error occured while migrating";
} catch (Exception $e) {
echo $e->getMessage();
}
}