本文整理汇总了PHP中query_db函数的典型用法代码示例。如果您正苦于以下问题:PHP query_db函数的具体用法?PHP query_db怎么用?PHP query_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了query_db函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_xml_tutorial
function save_xml_tutorial(&$file)
{
global $username;
debug_msg("File type is XML");
$tmpfile = $file["tmp_name"];
$filename = $file["name"];
$filepath = "users/{$username}";
debug_msg("Path: {$filepath}");
$pathname = "{$filepath}/{$filename}";
debug_msg("File will be saved as ../{$pathname}");
// Check if file exists and if not, write the data
if (file_exists("../{$pathname}")) {
debug_msg("File exists - temporary storage");
if (!is_dir("../{$filepath}/temp/")) {
mkdir("../{$filepath}/temp/");
}
move_uploaded_file($tmpfile, "../{$filepath}/temp/{$filename}");
$result = false;
} else {
move_uploaded_file($tmpfile, "../{$pathname}");
debug_msg("Move succeeded");
// update database
$filenoext = stripextension($filename);
open_db();
$date = date("Y-m-d");
$sql = "INSERT INTO file (file_date, file_author, file_path, file_name)" . " VALUES ('{$date}','{$username}','{$filepath}','{$filenoext}')" . " ON DUPLICATE KEY UPDATE file_date='{$date}';";
query_db($sql);
$result = $filenoext;
}
return $result;
}
示例2: is_damaged
function is_damaged($isbn, $copy)
{
include $_SERVER['DOCUMENT_ROOT'] . '/project/includes/db.inc.php';
$select = 'SELECT is_damaged';
$from = ' FROM book_copies';
$where = ' WHERE isbn LIKE "' . $isbn . '" AND copy_num LIKE "' . $copy . '"';
$result = query_db($link, $select . $from . $where);
$book = mysqli_fetch_array($result);
if ($book['is_damaged']) {
return true;
}
return false;
}
示例3: resetPasswordByToken
function resetPasswordByToken($token)
{
$row = get_row_null(sprintf("SELECT * FROM reset_password_tokens LEFT JOIN user_info ON reset_password_tokens.uid = user_info.uid WHERE reset_password_tokens.token='%s';", mysql_real_escape_string($token)));
if (!$row) {
return FALSE;
}
// check for token expiry
$now = time();
$tokentime = strtotime($row["timestamp"]);
if ($now - $tokentime > 24 * 60 * 60) {
return FALSE;
}
resetPassword($row, NULL);
query_db(sprintf("DELETE FROM reset_password_tokens WHERE token='%s';", mysql_real_escape_string($token)));
return TRUE;
}
示例4: connect_db
<?php
# This file is part of MachDB. For license info, read LICENSE
include 'include/config.php';
include 'include/common.php';
include 'include/smarty.php';
# connect to DB
$db = connect_db($mysqlserver, $mysqluser, $mysqlpassword, $mysqldatabase);
$queryhostid = $_GET['id'];
# query pkgs
$pkg_query = query_db("SELECT pkg.name,pkg.version,pkg.release,pkg.arch,host_pkg.timestamp,host_pkg.id AS host_pkg_id,pkg.id FROM pkg,host_pkg WHERE host_pkg.host_id = '{$queryhostid}' AND pkg.id = host_pkg.pkg_id ORDER BY timestamp,name");
while ($_row = mysql_fetch_assoc($pkg_query)) {
$pkg[] = $_row;
}
$smarty->assign('pkg', $pkg);
$smarty->assign('hostid', $queryhostid);
$smarty->display('pkg.tpl');
close_db($db);
?>
示例5: query_db
<?php
require_once "connect.php";
// Gives us $con
require_once "thermo_functions.php";
require_once "constants.php";
$qry_str = 'SELECT `value` FROM `status` WHERE `id`
IN (' . CURRENT_SETPOINT_ID . ', ' . CURRENT_TEMP_ID . ', ' . MODE_ID . ',
' . OCCUPIED_ID . ', ' . HEAT_STATUS_ID . ', ' . COOL_STATUS_ID . ',
' . FAN_STATUS_ID . ') ORDER BY `id` ASC;';
$result = query_db($con, $qry_str);
# 1
$entry = fetch_array_db($result);
$return['current_temp'] = $entry['value'];
# 2
$entry = fetch_array_db($result);
$return['current_setpoint'] = $entry['value'];
# 3
$entry = fetch_array_db($result);
$return['mode'] = $entry['value'];
# 18
$entry = fetch_array_db($result);
$return['occupied'] = $entry['value'];
# 19
$entry = fetch_array_db($result);
$return['heat_status'] = $entry['value'];
# 20
$entry = fetch_array_db($result);
$return['cool_status'] = $entry['value'];
# 21
$entry = fetch_array_db($result);
示例6: query_db
query_db($link, $insert . $values);
$update = 'UPDATE book_copies';
$set = ' SET is_on_hold = 1';
$where = ' WHERE isbn LIKE "' . $book['isbn'] . '" AND copy_num LIKE "' . $book['copy'] . '"';
query_db($link, $update . $set . $where);
}
if (isset($_GET['futurehold'])) {
session_start();
include $_SERVER['DOCUMENT_ROOT'] . '/project/includes/db.inc.php';
$isbn = mysqli_real_escape_string($link, $_POST['isbn']);
$user = mysqli_real_escape_string($link, $_SESSION['user']);
$select = 'SELECT isbn, copy_num, MAX(return_date) as exp_date';
$from = ' FROM issues NATURAL JOIN book_copies';
$where = ' WHERE isbn LIKE "' . $isbn . '" AND ' . 'is_checked_out=1 AND is_on_hold=0 AND is_returned=0 AND is_damaged=0';
$result = query_db($link, $select . $from . $where);
if (mysqli_num_rows($result) > 0) {
$book = mysqli_fetch_array($result);
$update = 'UPDATE book_copies';
$set = ' SET is_on_hold=1, future_requester="' . $user . '"';
$where = ' WHERE isbn LIKE "' . $book['isbn'] . '" AND copy_num LIKE "' . $book['copy_num'] . '"';
echo $update . $set . $where;
query_db($link, $update . $set . $where);
$insert = 'INSERT INTO issues (username, isbn, copy_num, issue_date, return_date)';
$values = ' VALUES ("' . $user . '", "' . $book['isbn'] . '", "' . $book['copy_num'] . '", "' . $book['exp_date'] . '", DATE_ADD("' . $book['exp_date'] . '", INTERVAL 17 DAY))';
echo $insert . $values;
query_db($link, $insert . $values);
} else {
$error = 'Book is on hold';
}
}
include 'search.html.php';
示例7: has_result
function has_result($query)
{
$result = query_db($query);
return mysql_num_rows($result) > 0;
}
示例8: outputPlugins
function outputPlugins()
{
connect_db();
$ordervar = @$_GET["order"] ? quote_db(@$_GET["order"]) : "moddate";
$asc_desc = @$_GET["sort"] ? quote_db(@$_GET["sort"]) : "DESC";
$result = query_db("SELECT * FROM plugins ORDER BY {$ordervar} {$asc_desc}");
$now = time();
$i = 0;
while ($row = mysql_fetch_array($result)) {
$moddate_unix = strtotime($row['moddate']);
$odd = $i % 2 == 1;
$image_file = file_exists($row['image']) ? $row['image'] : "images/noicon.png";
echo '<div class="box name' . ($odd ? ' odd' : '') . '" >';
echo ' <img src="' . $image_file . '" alt="plugin icon" />';
echo ' <a href="http://qsapp.com/plugins/plugins/' . $row['fullpath'] . '">' . $row['name'] . '</a>';
if ($now - $moddate_unix <= 5184000) {
echo ' <sup><span style="color:#ff0000;" >new!</span></sup>';
}
echo '</div>';
echo '<div class="box version' . ($odd ? ' odd' : '') . '" >' . $row['version'] . ' </div>';
echo '<div class="box updated' . ($odd ? ' odd' : '') . '" >' . $row['moddate'] . ' </div>';
// <div class="box" id="dl"><a href="'.$row['fullpath'].'"><img src="images/download.gif" /></a></div>';
$i++;
}
echo '<p> </p>';
close_db();
}
示例9: fwrite
fwrite($file, $data);
fclose($file);
debug_msg("File written");
// select database
open_db();
// Is there a file in the DB with this name & path?
$sql = "SELECT file_id FROM file WHERE file_name='{$filename}' AND file_path='{$filepath}';";
$date = date("Y-m-d");
$reply = "File {$filename} ";
if ($key = query_one_item($sql)) {
$sql = "UPDATE file SET file_date='" . $date . "' WHERE file_id = " . $key . ";";
$reply .= "updated.";
} else {
$sql = "INSERT INTO file (file_date, file_author, file_path, file_name) " . "VALUES ('" . $date . "','" . $username . "','" . $filepath . "','" . $filename . "')";
$reply .= "created.";
}
query_db($sql);
// if a temp save exists, delete it
$pathname = "../run/users/{$username}/temp/{$filename}.xml";
if (file_exists($pathname)) {
unlink($pathname);
debug_msg("Temp save removed");
}
echo $reply . "\n";
echo "../users/{$username}/{$filename}.xml";
} else {
// file does not exist despite fopen
header("HTTP/1.1 500 Internal Server Error");
echo "\nFile could not be created";
}
exit;
示例10: query_db
query_db("ALTER TABLE `disk` CHANGE `size` `size` bigint UNSIGNED NOT NULL;");
print "ALTER TABLE `filesystem` CHANGE `size` `size` bigint UNSIGNED NOT NULL;\n";
query_db("ALTER TABLE `filesystem` CHANGE `size` `size` bigint UNSIGNED NOT NULL;");
print "ALTER TABLE `archive_filesystem` CHANGE `size` `size` bigint UNSIGNED NOT NULL;\n";
query_db("ALTER TABLE `archive_filesystem` CHANGE `size` `size` bigint UNSIGNED NOT NULL;");
# OS name can be over 30 characters, change to 100
print "ALTER TABLE `os` CHANGE `name` `name` varchar(100) NOT NULL DEFAULT '' ;\n";
query_db("ALTER TABLE `os` CHANGE `name` `name` varchar(100) NOT NULL DEFAULT '' ;");
# cpu gets unified_cache filed
print "ALTER TABLE `cpu` ADD `unified_cache` int(1) DEFAULT NULL AFTER `cache`;\n";
query_db("ALTER TABLE `cpu` ADD `unified_cache` int(1) DEFAULT NULL AFTER `cache`;");
# packages add 'release'
print "ALTER TABLE `pkg` ADD `release` varchar(30) DEFAULT NULL AFTER `version`;\n";
query_db("ALTER TABLE `pkg` ADD `release` varchar(30) DEFAULT NULL AFTER `version`;");
print "ALTER TABLE `pkg` ADD INDEX (`release`);\n";
query_db("ALTER TABLE `pkg` ADD INDEX (`release`);");
// If you want to use the 'release' field, uncomment the following block.
/*
# put all the pkg from db in an array
$result = query_db("SELECT * FROM `pkg` where `release` is NULL");
while ($pkg = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $pkg["id"];
$name = $pkg["name"];
$db_version = $pkg["version"];
list($version,$release) = split("-", $db_version);
query_db("UPDATE `pkg` SET `version` = '$version', `release` = '$release' WHERE `id` = '$id'");
#print("UPDATE `pkg` SET `version` = '$version', `release` = '$release' WHERE `id` = '$id'\n");
print("$name: $version - $release\n");
}
*/
close_db($db);
示例11: explode
$location = $_POST['location'];
// array. first item - lowest boundary, second - highest
$range = explode('-', $_POST['price_range']);
// range string for sql
if ($range[0] == 0) {
// if option any is selected,
$range_sql = "";
} else {
if ($range[0] == 500000) {
$range_sql = " AND price > '500000'";
} else {
$range_sql = " AND (price > '" . escape($db, $range[0]) . "' AND price < '" . escape($db, $range[1]) . "' )";
}
}
$search_qry = "SELECT id, street, bedrooms, " . "bathrooms, squarefeet, description, photo, price " . "FROM properties " . "WHERE city='" . $db->real_escape_string($location) . "'" . $range_sql;
$search_result = query_db($db, $search_qry);
// HTML generation
session_start();
echo "<p style=\"float: right;\">Welcome, " . $_SESSION['name'];
// HTML generation
echo "<p class=\"red_italics\">There are the properties that matched your search criteria in {$location}</p>";
echo "<table border=\"1px black solid\">";
echo "<tr><td>Street</td>" . "<td>Bedrooms</td>" . "<td>Bathrooms</td>" . "<td>Squarefeet</td>" . "<td>Description</td>" . "<td>Photo</td><td>Price</td></tr>";
foreach ($search_result as $item) {
echo "<tr>";
foreach ($item as $key => $subitem) {
if ($key == 'id') {
continue;
}
// skip id part
if ($key == 'photo') {
示例12: query_db
}
$query = query_db("SELECT DISTINCT arch FROM os ORDER BY arch");
while ($_row = mysql_fetch_assoc($query)) {
$os_arch[] = $_row;
}
$query = query_db("SELECT DISTINCT vendor FROM os ORDER BY vendor");
while ($_row = mysql_fetch_assoc($query)) {
$os_vendor[] = $_row;
}
$query = query_db("SELECT DISTINCT name FROM pkg ORDER BY name");
while ($_row = mysql_fetch_assoc($query)) {
$pkg_name[] = $_row;
$pkg_name_index_word = $_row['name'];
$pkg_name_index[] = substr($pkg_name_index_word, 0, 1);
}
$query = query_db("SELECT DISTINCT arch FROM pkg ORDER BY arch");
while ($_row = mysql_fetch_assoc($query)) {
$pkg_arch[] = $_row;
}
$smarty->assign('os', $os);
$smarty->assign('kernel', $kernel);
$smarty->assign('os_arch', $os_arch);
$smarty->assign('os_vendor', $os_vendor);
$smarty->assign('pkg_name_index', $pkg_name_index);
$smarty->assign('pkg_name', $pkg_name);
$smarty->assign('pkg_arch', $pkg_name);
$smarty->assign('date', $date);
$smarty->assign('pagetitle', $pagetitle);
$smarty->assign('querystring', $querystring);
$smarty->display('software.tpl');
close_db($db);
示例13: query_db
<?php
require_once 'mysql_login.php';
$bbc_total = query_db("SELECT SUM(bbc) FROM tblUsers");
$bbc_total = mysql_fetch_array($bbc_total)[0];
$guardian_total = query_db("SELECT SUM(guardian) FROM tblUsers");
$guardian_total = mysql_fetch_array($guardian_total)[0];
$telegraph_total = query_db("SELECT SUM(telegraph) FROM tblUsers");
$telegraph_total = mysql_fetch_array($telegraph_total)[0];
$dailymail_total = query_db("SELECT SUM(dailymail) FROM tblUsers");
$dailymail_total = mysql_fetch_array($dailymail_total)[0];
$times_total = query_db("SELECT SUM(times) FROM tblUsers");
$times_total = mysql_fetch_array($times_total)[0];
$sun_total = query_db("SELECT SUM(sun) FROM tblUsers");
$sun_total = mysql_fetch_array($sun_total)[0];
$total = $bbc_total + $guardian_total + $telegraph_total + $dailymail_total + $times_total + $sun_total;
$np = $_GET['np'];
$np_total = query_db("SELECT SUM({$np}) FROM tblUsers");
$np_total = mysql_fetch_array($np_total)[0];
$np_percent = $np_total / $total * 100;
echo $np_percent;
示例14: open_db
</head>
<body>
<?php
$file_id = $_GET["file"];
// Make the query
// select database
open_db();
$sql = "SELECT *, count(load_id) AS popularity FROM file";
$sql .= " LEFT JOIN file_use ON (file.file_id = file_use.file_id)";
$sql .= " WHERE (file.file_id={$file_id}) AND (file_author='{$username}') GROUP BY file.file_id";
$result = query_db($sql);
if ($record = mysqli_fetch_array($result)) {
$sql2 = "select tag from file_tag WHERE file_id=" . $file_id;
$tags = query_db($sql2);
if ($tag = mysqli_fetch_array($tags)) {
$tagcell = $tag["tag"];
while ($tag = mysqli_fetch_array($tags)) {
$tagcell = $tagcell . "; " . $tag["tag"];
}
} else {
$tagcell = "";
}
?>
<form name="filedetails" action="file_manager.php"
onSubmit="opener.focus();" onCancel="opener.focus();" method="post" >
<b>File details</b> <br />
<input type="hidden" name="key" value="<?php
echo $file_id;
?>
示例15: connect_db
$db = connect_db($mysqlserver, $mysqluser, $mysqlpassword, $mysqldatabase);
$query = $_GET;
$archive = $_GET[archive];
# loop thru the variables in the query
foreach ($query as $key => $variable) {
$querystring[] = " {$key}={$variable}";
$variable = str_replace("*", "%", $variable);
# host search
if ($key == "hostname") {
$hostname_query = query_db("SELECT hostname,id,timestamp FROM host WHERE {$key} LIKE '%{$variable}%' ORDER BY hostname");
while ($_row = mysql_fetch_array($hostname_query)) {
$hostname[] = $_row;
}
# if 'archive' is clicked
if ($archive == "on") {
$hostname_query = query_db("SELECT hostname,id,timestamp FROM archive_host WHERE {$key} LIKE '%{$variable}%' ORDER BY hostname");
while ($_row = mysql_fetch_array($hostname_query)) {
$hostname[] = $_row;
}
}
$smarty->assign('hostname', $hostname);
} else {
$smarty->assign('noquery', $_GET);
}
}
$smarty->assign('date', $date);
$smarty->assign('pagetitle', $pagetitle);
$smarty->assign('querystring', $querystring);
$smarty->display('search.tpl');
close_db($db);
?>