本文整理汇总了PHP中queries函数的典型用法代码示例。如果您正苦于以下问题:PHP queries函数的具体用法?PHP queries怎么用?PHP queries使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了queries函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sqlquery
function sqlquery($requete, $number)
{
$query = mysql_query($requete) or exit('Erreur SQL : ' . mysql_error() . ' Ligne : ' . __LINE__ . '.');
//requête
queries();
/*
Deux cas possibles ici :
Soit on sait qu'on a qu'une seule entrée qui sera
retournée par SQL, donc on met $number à 1
Soit on ne sait pas combien seront retournées,
on met alors $number à 2.
*/
if ($number == 1) {
$query1 = mysql_fetch_assoc($query);
mysql_free_result($query);
/*mysql_free_result($query) libère le contenu de $query, je
le fais par principe, mais c'est pas indispensable.*/
return $query1;
} else {
if ($number == 2) {
while ($query1 = mysql_fetch_assoc($query)) {
$query2[] = $query1;
/*On met $query1 qui est un array dans $query2 qui
est un array. Ca fait un array d'arrays :o*/
}
mysql_free_result($query);
return $query2;
} else {
exit('Argument de sqlquery non renseigné ou incorrect.');
}
}
}
示例2: insertUpdate
function insertUpdate($table, $rows, $primary)
{
$columns = array_keys(reset($rows));
$prefix = "INSERT INTO " . table($table) . " (" . implode(", ", $columns) . ") VALUES\n";
$values = array();
foreach ($columns as $key) {
$values[$key] = "{$key} = VALUES({$key})";
}
$suffix = "\nON DUPLICATE KEY UPDATE " . implode(", ", $values);
$values = array();
$length = 0;
foreach ($rows as $set) {
$value = "(" . implode(", ", $set) . ")";
if ($values && strlen($prefix) + $length + strlen($value) + strlen($suffix) > 1000000.0) {
// 1e6 - default max_allowed_packet
if (!queries($prefix . implode(",\n", $values) . $suffix)) {
return false;
}
$values = array();
$length = 0;
}
$values[] = $value;
$length += strlen($value) + 2;
// 2 - strlen(",\n")
}
return queries($prefix . implode(",\n", $values) . $suffix);
}
示例3: array_diff
$revoke = array_diff(array_keys(array_filter($new_grants[$object], 'strlen')), $grant);
} elseif ($old_user == $new_user) {
$old_grant = array_keys((array) $grants[$object]);
$revoke = array_diff($old_grant, $grant);
$grant = array_diff($grant, $old_grant);
unset($grants[$object]);
}
if (preg_match('~^(.+)\\s*(\\(.*\\))?$~U', $object, $match) && (!grant("REVOKE", $revoke, $match[2], " ON {$match['1']} FROM {$new_user}") || !grant("GRANT", $grant, $match[2], " ON {$match['1']} TO {$new_user}"))) {
$error = true;
break;
}
}
}
if (!$error && isset($_GET["host"])) {
if ($old_user != $new_user) {
queries("DROP USER {$old_user}");
} elseif (!isset($_GET["grant"])) {
foreach ($grants as $object => $revoke) {
if (preg_match('~^(.+)(\\(.*\\))?$~U', $object, $match)) {
grant("REVOKE", array_keys($revoke), $match[2], " ON {$match['1']} FROM {$new_user}");
}
}
}
}
queries_adminer_redirect(ME . "privileges=", isset($_GET["host"]) ? lang('User has been altered.') : lang('User has been created.'), !$error);
if ($created) {
// delete new user in case of an error
$connection->query("DROP USER {$new_user}");
}
}
}
示例4: copy_tables
$result = copy_tables((array) $_POST["tables"], (array) $_POST["views"], $_POST["target"]);
$message = lang('Tables have been copied.');
} elseif ($_POST["drop"]) {
if ($_POST["views"]) {
$result = drop_views($_POST["views"]);
}
if ($result && $_POST["tables"]) {
$result = drop_tables($_POST["tables"]);
}
$message = lang('Tables have been dropped.');
} elseif ($jush != "sql") {
$result = $jush == "sqlite" ? queries("VACUUM") : apply_queries("VACUUM" . ($_POST["optimize"] ? "" : " ANALYZE"), $_POST["tables"]);
$message = lang('Tables have been optimized.');
} elseif (!$_POST["tables"]) {
$message = lang('No tables.');
} elseif ($result = queries(($_POST["optimize"] ? "OPTIMIZE" : ($_POST["check"] ? "CHECK" : ($_POST["repair"] ? "REPAIR" : "ANALYZE"))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))) {
while ($row = $result->fetch_assoc()) {
$message .= "<b>" . h($row["Table"]) . "</b>: " . h($row["Msg_text"]) . "<br>";
}
}
queries_redirect(substr(ME, 0, -1), $message, $result);
}
page_header($_GET["ns"] == "" ? lang('Database') . ": " . h(DB) : lang('Schema') . ": " . h($_GET["ns"]), $error, true);
if ($adminer->homepage()) {
if ($_GET["ns"] !== "") {
echo "<h3 id='tables-views'>" . lang('Tables and views') . "</h3>\n";
$tables_list = tables_list();
if (!$tables_list) {
echo "<p class='message'>" . lang('No tables.') . "\n";
} else {
echo "<form action='' method='post'>\n";
示例5: trigger
$row = (array) trigger($name) + array("Trigger" => $TABLE . "_bi");
if ($_POST) {
if (!$error && in_array($_POST["Timing"], $trigger_options["Timing"]) && in_array($_POST["Event"], $trigger_options["Event"]) && in_array($_POST["Type"], $trigger_options["Type"])) {
// don't use drop_create() because there may not be more triggers for the same action
$on = " ON " . table($TABLE);
$drop = "DROP TRIGGER " . idf_escape($name) . ($jush == "pgsql" ? $on : "");
$location = ME . "table=" . urlencode($TABLE);
if ($_POST["drop"]) {
query_adminer_redirect($drop, $location, lang('Trigger has been dropped.'));
} else {
if ($name != "") {
queries($drop);
}
queries_adminer_redirect($location, $name != "" ? lang('Trigger has been altered.') : lang('Trigger has been created.'), queries(create_trigger($on, $_POST)));
if ($name != "") {
queries(create_trigger($on, $row + array("Type" => reset($trigger_options["Type"]))));
}
}
}
$row = $_POST;
}
page_header($name != "" ? lang('Alter trigger') . ": " . h($name) : lang('Create trigger'), $error, array("table" => $TABLE));
?>
<form action="" method="post" id="form">
<table cellspacing="0">
<tr><th><?php
echo lang('Time');
?>
<td><?php
echo html_select("Timing", $trigger_options["Timing"], $row["Timing"], "triggerChange(/^" . preg_quote($TABLE, "/") . "_[ba][iud]\$/, '" . is_adminer_escape($TABLE) . "', this.form);");
示例6: idf_escape
$set[idf_escape($name)] = $val !== false ? $val : idf_escape($name);
}
}
}
if ($_POST["delete"] || $set) {
if ($_POST["clone"]) {
$query = "INTO " . adminer_table($TABLE) . " (" . implode(", ", array_keys($set)) . ")\nSELECT " . implode(", ", $set) . "\nFROM " . adminer_table($TABLE);
}
if ($_POST["all"] || $unselected === array() && is_array($_POST["check"]) || $is_group) {
$result = $_POST["delete"] ? $driver->delete($TABLE, $where_check) : ($_POST["clone"] ? queries("INSERT {$query}{$where_check}") : $driver->update($TABLE, $set, $where_check));
$affected = $connection->affected_rows;
} else {
foreach ((array) $_POST["check"] as $val) {
// where is not unique so OR can't be used
$where2 = "\nWHERE " . ($where ? implode(" AND ", $where) . " AND " : "") . where_check($val, $fields);
$result = $_POST["delete"] ? $driver->delete($TABLE, $where2, 1) : ($_POST["clone"] ? queries("INSERT" . limit1($query, $where2)) : $driver->update($TABLE, $set, $where2));
if (!$result) {
break;
}
$affected += $connection->affected_rows;
}
}
}
$message = lang('%d item(s) have been affected.', $affected);
if ($_POST["clone"] && $result && $affected == 1) {
$last_id = last_id();
if ($last_id) {
$message = lang('Item%s has been inserted.', " {$last_id}");
}
}
queries_adminer_redirect(remove_from_uri($_POST["all"] && $_POST["delete"] ? "page" : ""), $message, $result);
示例7: usersMenus
exit;
}
}else{
$user=new usersMenus();
if(!$user->AsWebStatisticsAdministrator){
$tpl=new templates();
echo "alert('".$tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
exit;
}
}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["graph"])){echo graph();exit;}
if(isset($_GET["browsed"])){echo browsed_websites();exit;}
if(isset($_GET["browsed-popup"])){echo browsed_websites_popup();exit;}
if(isset($_GET["queries"])){queries();exit;}
if(isset($_GET["last-events"])){last_events();exit;}
if(isset($_GET["query-menu"])){query_menu();exit;}
if(isset($_GET["popup-filter"])){popup_filter();exit;}
if(isset($_GET["Q_CLIENT"])){saveFilter();exit;}
if(isset($_GET["show-hits"])){showhits();exit;}
js();
function thumbnail_zoom_js(){
$page=CurrentPageName();
$html="YahooSearchUser('430','$page?thumbnail-zoom-popup={$_GET["thumbnail-zoom-js"]}','{$_GET["thumbnail-zoom-js"]}');";
echo $html;
示例8: array
} else {
$set = array();
foreach ($matches2[1] as $i => $col) {
$set[idf_escape($cols[$i])] = $col == "" && $fields[$cols[$i]]["null"] ? "NULL" : q(str_replace('""', '"', preg_replace('~^"|"$~', '', $col)));
}
$result = insert_update($TABLE, $set, $primary);
if (!$result) {
break;
}
}
}
if ($result) {
queries("COMMIT");
}
queries_redirect(remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result);
queries("ROLLBACK");
// after queries_redirect() to not overwrite error
} else {
$error = upload_error($file);
}
}
}
$table_name = $adminer->tableName($table_status);
if (is_ajax()) {
// needs to send headers
ob_start();
}
page_header(lang('Select') . ": {$table_name}", $error);
$set = null;
if (isset($rights["insert"])) {
$set = "";
示例9: foreach
<?php
if (support("kill") && $_POST && !$error) {
$killed = 0;
foreach ((array) $_POST["kill"] as $val) {
if (queries("KILL " . +$val)) {
$killed++;
}
}
queries_redirect(ME . "processlist=", lang('%d process(es) have been killed.', $killed), $killed || !$_POST["kill"]);
}
page_header(lang('Process list'), $error);
?>
<form action="" method="post">
<table cellspacing="0" onclick="tableClick(event);" class="nowrap checkable">
<?php
// HTML valid because there is always at least one process
$i = -1;
foreach (process_list() as $i => $row) {
if (!$i) {
echo "<thead><tr lang='en'>" . (support("kill") ? "<th> " : "") . "<th>" . implode("<th>", array_keys($row)) . "</thead>\n";
}
echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row["Id"], 0) : "");
foreach ($row as $key => $val) {
echo "<td>" . ($jush == "sql" && $key == "Info" && ereg("Query|Killed", $row["Command"]) && $val != "" || $jush == "pgsql" && $key == "current_query" && $val != "<IDLE>" || $jush == "oracle" && $key == "sql_text" && $val != "" ? "<code class='jush-{$jush}'>" . shorten_utf8($val, 100, "</code>") . ' <a href="' . h(ME . ($row["db"] != "" ? "db=" . urlencode($row["db"]) . "&" : "") . "sql=" . urlencode($val)) . '">' . lang('Edit') . '</a>' : nbsp($val));
}
echo "\n";
}
?>
</table>
示例10: drop_create
/** Drop old object and create a new one
* @param string drop query
* @param string create query
* @param string
* @param string
* @param string
* @param string
* @param string
* @return bool dropped
*/
function drop_create($drop, $create, $location, $message_drop, $message_alter, $message_create, $name)
{
if ($_POST["drop"]) {
return query_redirect($drop, $location, $message_drop, true, !$_POST["dropped"]);
}
$dropped = $name != "" && ($_POST["dropped"] || queries($drop));
$created = queries($create);
if (!queries_redirect($location, $name != "" ? $message_alter : $message_create, $created) && $dropped) {
redirect(null, $message_drop);
}
return $dropped;
}
示例11: foreach
<?php
if (support("kill") && $_POST && !$error) {
$killed = 0;
foreach ((array) $_POST["kill"] as $val) {
if (queries("KILL " . number($val))) {
$killed++;
}
}
queries_redirect(ME . "processlist=", lang('%d process(es) have been killed.', $killed), $killed || !$_POST["kill"]);
}
page_header(lang('Process list'), $error);
?>
<form action="" method="post">
<table cellspacing="0" onclick="tableClick(event);" ondblclick="tableClick(event, true);" class="nowrap checkable">
<?php
// HTML valid because there is always at least one process
$i = -1;
foreach (process_list() as $i => $row) {
if (!$i) {
echo "<thead><tr lang='en'>" . (support("kill") ? "<th> " : "");
foreach ($row as $key => $val) {
echo "<th>{$key}" . doc_link(array('sql' => "show-processlist.html#processlist_" . strtolower($key), 'pgsql' => "monitoring-stats.html#PG-STAT-ACTIVITY-VIEW", 'oracle' => "../b14237/dynviews_2088.htm"));
}
echo "</thead>\n";
}
echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row["Id"], 0) : "");
foreach ($row as $key => $val) {
echo "<td>" . ($jush == "sql" && $key == "Info" && preg_match("~Query|Killed~", $row["Command"]) && $val != "" || $jush == "pgsql" && $key == "current_query" && $val != "<IDLE>" || $jush == "oracle" && $key == "sql_text" && $val != "" ? "<code class='jush-{$jush}'>" . shorten_utf8($val, 100, "</code>") . ' <a href="' . h(ME . ($row["db"] != "" ? "db=" . urlencode($row["db"]) . "&" : "") . "sql=" . urlencode($val)) . '">' . lang('Clone') . '</a>' : nbsp($val));
}
示例12: queries
<td><h6><b><?php
echo $row['date_published'];
?>
</b></h6></td>
</tr>
</table>
</div>
</a>
<?php
}
}
}
} else {
$select_all_recipes = "SELECT * FROM recipes WHERE recipes.date_deleted IS NULL ";
$r = queries($connect, $select_all_recipes);
echo '<p><h3 class="h3">Всички рецепти</h3></p>';
if (mysqli_num_rows($r) > 0) {
//while ($row = mysqli_fetch_assoc($r)) {
///////////////////////////// започва общия слайдер, когато не е избран никакъв тип рецепта ////////////////////////////////
?>
<div id="sliderFrame">
<div id="slider">
<?php
$select_rec = "SELECT * FROM recipes WHERE size_photo > 0 AND recipes.date_deleted IS NULL ORDER BY id DESC LIMIT 4";
// взима последните добавени рецепти със снимка
$query_rec = mysqli_query($connect, $select_rec) or die(mysqli_error());
if (mysqli_num_rows($query_rec) > 0) {
while ($r = mysqli_fetch_assoc($query_rec)) {
echo '<a href="recipies.php?recipie=' . $r['id_food_type'] . '&view=' . $r['id'] . '">';
示例13: updateConnectes
function updateConnectes($id)
{
$ip = getIp();
if ($id != -1) {
$id = $_SESSION['mbrid'];
$additionnal = 1;
//la variable à mettre dans connectes_membre
} else {
$additionnal = $ip;
}
mysql_query("DELETE FROM connectes WHERE connectes_actualisation < " . (time() - 1600)) or exit(mysql_error());
//MàJ générale des connectés
mysql_query("INSERT INTO connectes VALUES(" . $id . ", '" . $ip . "', '" . $additionnal . "', " . time() . ")\n ON DUPLICATE KEY UPDATE connectes_actualisation=" . time() . ", connectes_ip='" . $ip . "'") or exit(mysql_error());
//on "duplicate"
queries(2);
}
示例14: drop_create
/** Drop old object and create a new one
* @param string drop old object query
* @param string create new object query
* @param string drop new object query
* @param string create test object query
* @param string drop test object query
* @param string
* @param string
* @param string
* @param string
* @param string
* @param string
* @return null redirect in success
*/
function drop_create($drop, $create, $drop_created, $test, $drop_test, $location, $message_drop, $message_alter, $message_create, $old_name, $new_name)
{
if ($_POST["drop"]) {
query_redirect($drop, $location, $message_drop);
} elseif ($old_name == "") {
query_redirect($create, $location, $message_create);
} elseif ($old_name != $new_name) {
$created = queries($create);
queries_redirect($location, $message_alter, $created && queries($drop));
if ($created) {
queries($drop_created);
}
} else {
queries_redirect($location, $message_alter, queries($test) && queries($drop_test) && queries($drop) && queries($create));
}
}
示例15: query_table
/**
* Echo log of database queries
*
* @param string $all
*/
function query_table()
{
$queries = queries();
$html = '<table style="background-color: #FFFF00;border: 1px solid #000000;color: #000000;padding-left: 10px;padding-right: 10px;width: 100%;">';
foreach ($queries as $query) {
$html .= '<tr style="border-top: 1px dashed #000000;"><td style="padding:8px;">' . e($query['look']) . '</td><td style="padding:8px;">' . e($query['time']) . '</td></tr>';
}
return $html . '</table>';
}