本文整理汇总了PHP中run_query函数的典型用法代码示例。如果您正苦于以下问题:PHP run_query函数的具体用法?PHP run_query怎么用?PHP run_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plogger_stats_count_total_comments
function plogger_stats_count_total_comments()
{
$query = "SELECT COUNT(*) AS `n` FROM `" . PLOGGER_TABLE_PREFIX . "comments` WHERE approved = 1";
$result = run_query($query);
$num_comments = mysqli_result($result, 0, 'n');
echo $num_comments . ' ';
echo $num_comments == 1 ? plog_tr('comment') : plog_tr('comments');
}
示例2: plogger_stats_count_total_comments
function plogger_stats_count_total_comments()
{
$query = "SELECT COUNT(*) AS \"n\" FROM \"" . PLOGGER_TABLE_PREFIX . "comments\" WHERE approved = 1";
$result = run_query($query);
$num_comments = $result->fetch()['n'];
echo $num_comments . ' ';
echo $num_comments == 1 ? plog_tr('comment') : plog_tr('comments');
}
示例3: fetch_url
function fetch_url($product)
{
$sql = "SELECT link FROM product WHERE prod_name= '" . $product . "'";
$result = run_query($sql);
while ($row = mysqli_fetch_assoc($result)) {
$url = $row['link'];
}
return $url;
}
示例4: exec_query
function exec_query($conn, $query)
{
$res = run_query($conn, $query);
while ($row = mysql_fetch_assoc($res)) {
$return[] = $row;
}
// mysql_free_result($res);
// print_r($return);
return $return;
}
示例5: get_tag_by_id
function get_tag_by_id($tag_id)
{
global $TABLE_PREFIX;
$existing_tag = array();
$tag_id = intval($tag_id);
$query = 'SELECT `id`, `tag`, `urlified` FROM `' . $TABLE_PREFIX . 'tags` WHERE `id`=' . $tag_id;
$result = run_query($query);
$row = mysql_fetch_assoc($result);
if (!is_array($row)) {
return NULL;
}
return array('id' => $row['tag_id'], 'tag' => $row['tag'], 'urlified' => $row['urlified']);
}
示例6: delete_bags
function delete_bags($conn, $bags)
{
if (!$bags) {
return;
}
if (sizeof($bags) == 1) {
$where = " id = {$bags[0]} ";
} else {
$where = " id in (" . implode(',', $bags) . ") ";
}
$query = "delete from bags where " . $where;
print $query;
run_query($conn, $query);
print ".. DONE<br/>";
}
示例7: process_report
function process_report($report, $xml)
{
$report = array();
$sql = array();
$query = array();
$format = array();
$result = array();
foreach ($xml as $key => $value) {
if ($key == 'title') {
$title = $value;
}
if ($key == 'description') {
$description = $value;
}
if ($key == 'query') {
if (isset($value['_content'])) {
$sql[$value['name']] = $value['_content'];
$query[$value['name']] = $value['title'];
} else {
foreach ($value as $key_sql => $value_sql) {
$sql[$value_sql['name']] = $value_sql['_content'];
$query[$value_sql['name']] = $value_sql['title'];
}
}
}
if ($key == 'column') {
$format = $value;
}
}
require_once __ROOT__ . '/tpl/report_hdr.tpl';
$timestamp = date('Ymdhis');
$chartData = '';
foreach ($sql as $sql_key => $sql_value) {
$result = run_query($sql_value, $parms);
if ($result) {
foreach ($result as $key => $value) {
if ($value) {
$html .= build_html($html, $chartData, $query, $sql_key, $value, $report_name, $title, $description, $parms, $format, $timestamp);
}
}
}
}
echo $chartData;
echo "</script>\n";
echo $html;
require_once __ROOT__ . '/tpl/report_ftr.tpl';
}
示例8: generate_breadcrumb_admin
function generate_breadcrumb_admin($level, $id = 0)
{
switch ($level) {
case 'collections':
$breadcrumbs = '<strong>' . plog_tr('Collections') . '</strong>';
break;
case 'albums':
$collection = get_collection_by_id($id);
$collection_name = SmartStripSlashes($collection['name']);
$breadcrumbs = '<a href="' . $_SERVER['PHP_SELF'] . '">' . plog_tr('Collections') . '</a> » <strong>' . $collection_name . '</strong>';
break;
case 'pictures':
$album = get_album_by_id($id);
$album_link = SmartStripSlashes($album['name']);
$collection_link = '<a href="' . $_SERVER['PHP_SELF'] . '?level=albums&id=' . $album['parent_id'] . '">' . SmartStripSlashes($album['collection_name']) . '</a>';
$breadcrumbs = '<a href="' . $_SERVER['PHP_SELF'] . '">' . plog_tr('Collections') . '</a> » ' . $collection_link . ' » ' . '<strong>' . $album_link . '</strong>';
break;
case 'comments':
$query = "SELECT * FROM `" . PLOGGER_TABLE_PREFIX . "pictures` WHERE `id`='" . $id . "'";
$result = run_query($query);
$row = mysql_fetch_assoc($result);
$picture_link = '<strong>' . SmartStripSlashes(basename($row['path'])) . '</strong>';
$album_id = $row['parent_album'];
$collection_id = $row['parent_collection'];
$query = "SELECT * FROM `" . PLOGGER_TABLE_PREFIX . "albums` WHERE `id`='" . $album_id . "'";
$result = run_query($query);
$row = mysql_fetch_assoc($result);
$album_link = '<a href="' . $_SERVER['PHP_SELF'] . '?level=pictures&id=' . $album_id . '">' . SmartStripSlashes($row['name']) . '</a>';
$query = "SELECT * FROM `" . PLOGGER_TABLE_PREFIX . "collections` WHERE `id`='" . $collection_id . "'";
$result = run_query($query);
$row = mysql_fetch_assoc($result);
$collection_link = '<a href="' . $_SERVER['PHP_SELF'] . '?level=albums&id=' . $collection_id . '">' . SmartStripSlashes($row['name']) . '</a>';
$breadcrumbs = '<a href="' . $_SERVER['PHP_SELF'] . '">' . plog_tr('Collections') . '</a> » ' . $collection_link . ' » ' . $album_link . ' » ' . $picture_link . ' - ' . '<strong>' . plog_tr('Comments') . ':</strong>';
break;
default:
$breadcrumbs = '<strong>' . plog_tr('Collections') . '</strong>';
}
return "\n\t\t" . '<div id="breadcrumb_links">' . $breadcrumbs . '</div>';
}
示例9: start_search
function start_search($scope, array $q_items = null)
{
switch ($scope) {
case 'random':
return random_search();
break;
case 'advanced-search':
if (empty($q_items)) {
return search_form(true);
} else {
return run_query($q_items);
}
break;
case 'search':
default:
if (!empty($q_items)) {
return run_query($q_items);
} else {
return search_form(false);
}
}
}
示例10: rand
print "</ul>";
print "<hr/>";
print "<h2>Actors! <a href='actor_form.php'>(Add)</a></h2>";
$random_actors_query = "select * from Actor order by rand() limit 5";
$random_actors = run_query($random_actors_query, $db_connection);
print "<ul>";
while ($random_actor_row = mysql_fetch_array($random_actors, MYSQL_ASSOC)) {
$actor_id = $random_actor_row['id'];
$actor_tag = $random_actor_row['first'] . " " . $random_actor_row['last'] . " (" . $random_actor_row['dob'] . ")";
$actor_link = "actor.php?actor_id={$actor_id}";
print "<li><a href={$actor_link}>{$actor_tag}</a></li>";
}
print "</ul>";
print "<hr/>";
print "<h2>Directors! <a href='director_form.php'>(Add)</a></h2>";
$random_directors_query = "select * from Director order by rand() limit 5";
$random_directors = run_query($random_directors_query, $db_connection);
print "<ul>";
while ($random_director_row = mysql_fetch_array($random_directors, MYSQL_ASSOC)) {
$director_id = $random_director_row['id'];
$director_tag = $random_director_row['first'] . " " . $random_director_row['last'] . " (" . $random_director_row['dob'] . ")";
$director_link = "director.php?director_id={$director_id}";
print "<li><a href={$director_link}>{$director_tag}</a></li>";
}
print "</ul>";
print "<hr/>";
close_connection($db_connection);
print "</body>";
?>
</html>
示例11: gr_add_album
function gr_add_album($parent, $name, $description)
{
// Parent is the name of the collection
$query = "SELECT * FROM \"" . PLOGGER_TABLE_PREFIX . "collections\" WHERE name = '" . $PLOGGER_DBH->quote($parent) . "'";
$result = run_query($query);
$row = $result->fetch();
if (empty($name)) {
$name = 'no name';
}
if (empty($description)) {
$description = 'no description';
}
$parent_id = $row['id'];
$result = add_album($name, $description, $parent_id);
global $response;
if (0 == $result['id']) {
$response->set_key('status', GR_STAT_CREATE_ALBUM_FAILED);
$response->set_key('status_text', 'Could not create album');
} else {
$response->set_key('status', GR_STAT_SUCCESS);
$response->set_key('status_text', 'Album created');
}
}
示例12: sanitize_string
$dob = sanitize_string($_GET["dob"], $db_connection);
$dod = NULL;
if ($_GET["dod"]) {
$dod = sanitize_string($_GET["dod"], $db_connection);
}
$person_type = sanitize_string($_GET["person_type"], $db_connection);
//print $person_type . "<br/>";
if ($person_type == "actor") {
$actor_base_query = "insert into Actor values (%d,'%s','%s','%s','%s','%s')";
$actor_query = sprintf($actor_base_query, $id, $last, $first, $sex, $dob, $dod);
//print $actor_query . "<br/>";
run_query($actor_query, $db_connection);
} else {
if ($person_type == "director") {
$director_base_query = "insert into Director values (%d,'%s','%s','%s','%s')";
$director_query = sprintf($director_base_query, $id, $last, $first, $dob, $dod);
//print $director_query . "<br/>";
run_query($director_query, $db_connection);
}
}
$max_person_update_query = sprintf("update MaxPersonID set id=%d where id=%d", $id, $old_max_person_id);
//print $max_person_update_query . "<br/>";
run_query($max_person_update_query, $db_connection);
close_connection($db_connection);
print "</body>";
if ($person_type == "actor") {
header("Location:actor.php?actor_id={$id}");
} else {
header("Location:director.php?director_id={$id}");
}
}
示例13: ss_get_mysql_stats
function ss_get_mysql_stats($options)
{
# Process connection options and connect to MySQL.
global $debug, $mysql_user, $mysql_pass, $heartbeat, $cache_dir, $poll_time, $chk_options, $mysql_port, $mysql_ssl;
# Connect to MySQL.
$user = isset($options['user']) ? $options['user'] : $mysql_user;
$pass = isset($options['pass']) ? $options['pass'] : $mysql_pass;
$port = isset($options['port']) ? $options['port'] : $mysql_port;
$heartbeat = isset($options['heartbeat']) ? $options['heartbeat'] : $heartbeat;
# If there is a port, or if it's a non-standard port, we add ":$port" to the
# hostname.
$host_str = $options['host'] . (isset($options['port']) || $port != 3306 ? ":{$port}" : '');
debug(array('connecting to', $host_str, $user, $pass));
if (!extension_loaded('mysql')) {
debug("The MySQL extension is not loaded");
die("The MySQL extension is not loaded");
}
if ($mysql_ssl || isset($options['mysql_ssl']) && $options['mysql_ssl']) {
$conn = mysql_connect($host_str, $user, $pass, true, MYSQL_CLIENT_SSL);
} else {
$conn = mysql_connect($host_str, $user, $pass);
}
if (!$conn) {
die("MySQL: " . mysql_error());
}
$sanitized_host = str_replace(array(":", "/"), array("", "_"), $options['host']);
$cache_file = "{$cache_dir}/{$sanitized_host}-mysql_cacti_stats.txt" . (isset($options['port']) || $port != 3306 ? ":{$port}" : '');
debug("Cache file is {$cache_file}");
# First, check the cache.
$fp = null;
if (!isset($options['nocache'])) {
if ($fp = fopen($cache_file, 'a+')) {
$locked = flock($fp, 1);
# LOCK_SH
if ($locked) {
if (filesize($cache_file) > 0 && filectime($cache_file) + $poll_time / 2 > time() && ($arr = file($cache_file))) {
# The cache file is good to use.
debug("Using the cache file");
fclose($fp);
return $arr[0];
} else {
debug("The cache file seems too small or stale");
# Escalate the lock to exclusive, so we can write to it.
if (flock($fp, 2)) {
# LOCK_EX
# We might have blocked while waiting for that LOCK_EX, and
# another process ran and updated it. Let's see if we can just
# return the data now:
if (filesize($cache_file) > 0 && filectime($cache_file) + $poll_time / 2 > time() && ($arr = file($cache_file))) {
# The cache file is good to use.
debug("Using the cache file");
fclose($fp);
return $arr[0];
}
ftruncate($fp, 0);
# Now it's ready for writing later.
}
}
} else {
debug("Couldn't lock the cache file, ignoring it.");
$fp = null;
}
}
} else {
$fp = null;
debug("Couldn't open the cache file");
}
# Set up variables.
$status = array('relay_log_space' => null, 'binary_log_space' => null, 'current_transactions' => 0, 'locked_transactions' => 0, 'active_transactions' => 0, 'innodb_locked_tables' => 0, 'innodb_tables_in_use' => 0, 'innodb_lock_structs' => 0, 'innodb_lock_wait_secs' => 0, 'innodb_sem_waits' => 0, 'innodb_sem_wait_time_ms' => 0, 'State_closing_tables' => null, 'State_copying_to_tmp_table' => null, 'State_end' => null, 'State_freeing_items' => null, 'State_init' => null, 'State_locked' => null, 'State_login' => null, 'State_preparing' => null, 'State_reading_from_net' => null, 'State_sending_data' => null, 'State_sorting_result' => null, 'State_statistics' => null, 'State_updating' => null, 'State_writing_to_net' => null, 'State_none' => null, 'State_other' => null);
# Get SHOW STATUS and convert the name-value array into a simple
# associative array.
$result = run_query("SHOW /*!50002 GLOBAL */ STATUS", $conn);
foreach ($result as $row) {
$status[$row[0]] = $row[1];
}
# Get SHOW VARIABLES and do the same thing, adding it to the $status array.
$result = run_query("SHOW VARIABLES", $conn);
foreach ($result as $row) {
$status[$row[0]] = $row[1];
}
# Get SHOW SLAVE STATUS, and add it to the $status array.
if ($chk_options['slave']) {
$result = run_query("SHOW SLAVE STATUS", $conn);
$slave_status_rows_gotten = 0;
foreach ($result as $row) {
$slave_status_rows_gotten++;
# Must lowercase keys because different MySQL versions have different
# lettercase.
$row = array_change_key_case($row, CASE_LOWER);
$status['relay_log_space'] = $row['relay_log_space'];
$status['slave_lag'] = $row['seconds_behind_master'];
# Check replication heartbeat, if present.
if ($heartbeat) {
$result2 = run_query("SELECT GREATEST(0, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(ts) - 1)" . " AS delay FROM {$heartbeat} WHERE id = 1", $conn);
$slave_delay_rows_gotten = 0;
foreach ($result2 as $row2) {
$slave_delay_rows_gotten++;
if ($row2 && is_array($row2) && array_key_exists('delay', $row2)) {
$status['slave_lag'] = $row2['delay'];
} else {
//.........这里部分代码省略.........
示例14: chdir
chdir(dirname(__FILE__));
function run_query($query)
{
echo $query . ";\n";
return true;
}
echo "\n\n-- ##### point_in_polygon.sql\n\n";
echo file_get_contents($basedir . 'mysql_feplus/point_in_polygon.sql');
echo "\n\n-- ##### feplus.sql\n\n";
echo file_get_contents($basedir . 'mysql_feplus/feplus.sql');
echo "\n\n-- ##### fedump.csv\n\n";
// make shape column hold text values
run_query("alter table feplus modify column shape TEXT");
// generate sql from data
$contents = file_get_contents($basedir . 'mysql_feplus/fedump.csv');
$lines = split("\n", $contents);
foreach ($lines as $line) {
if ($line != '') {
run_query("insert into feplus (s, m, e, h, l, area, shape, feregion, priority, dataset) values (" . $line . ")") or print mysql_error();
}
}
// now convert text values to polygons
run_query("alter table feplus ADD COLUMN polyshape POLYGON AFTER shape") or print mysql_error();
run_query("update feplus SET polyshape = GeomFromText(shape)") or print mysql_error();
run_query("alter table feplus DROP COLUMN shape") or print mysql_error();
run_query("alter table feplus CHANGE polyshape shape POLYGON NOT NULL") or print mysql_error();
run_query("alter table feplus ADD SPATIAL INDEX(shape)") or print mysql_error();
echo "\n\n-- #### productIndexSchemaMysql.sql\n\n";
echo file_get_contents($basedir . 'productIndexSchemaMysql.sql');
#echo "\n\n-- #### productIndexOnEventUpdateMysql.sql\n\n";
#echo file_get_contents($basedir . 'productIndexOnEventUpdateMysql.sql');
示例15: add_album
} else {
if ($_REQUEST['destination_radio'] == 'new') {
// Create the new album
$result = add_album(mysql_real_escape_string($_REQUEST['new_album_name']), NULL, $_REQUEST['collections_menu']);
if (!$result['errors']) {
// No errors, add uploaded image to new album
$album_id = $result['id'];
} else {
// Errors exist, let's find out what they are
if (isset($result['output']) && $result['output'] == 'existing' && isset($result['id'])) {
// Album already exists so try insert images into the existing album
// and alert the user that their "new" album is already existing
$album_id = $result['id'];
// Get the collection name for display
$sql = "SELECT `name` FROM " . PLOGGER_TABLE_PREFIX . "collections WHERE id = " . intval($_REQUEST['collections_menu']);
$result = run_query($sql);
$row = mysql_fetch_assoc($result);
$output .= "\n\t" . '<p class="actions">' . sprintf(plog_tr('Album already exists. Uploading file to existing album %s in collection %s'), '<strong>' . $_REQUEST['new_album_name'] . '</strong>', '<strong>' . $row['name'] . '</strong>') . '</p>' . "\n";
} else {
// Error has nothing to do with an existing album, show the returned error
$album_id = '';
$output .= "\n\t" . '<p class="errors">' . $result['errors'] . '</p>' . "\n";
}
}
} else {
// Use an existing album
$album_id = $_REQUEST['albums_menu'];
}
if ($album_id) {
$result = add_picture($album_id, $_FILES['userfile']['tmp_name'], $_FILES['userfile']['name'], $_REQUEST['caption'], $_REQUEST['description']);
if (!$result['errors']) {