本文整理汇总了PHP中get_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP get_rows函数的具体用法?PHP get_rows怎么用?PHP get_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade_075_080_pskills_migrate
function upgrade_075_080_pskills_migrate()
{
# Note: Requires the players_skills table AND all skills name corrections made in DB so they fit $skillsididx.
global $skillididx;
global $skillididx_rvs;
# Make global for use below (dirty trick).
$skillididx_rvs = array_flip($skillididx);
# Already run this version upgrade (note: this routine specifically does not remove the skills column(s))?
if (!SQLUpgrade::doesColExist('players', 'ach_nor_skills')) {
return true;
}
$status = true;
$status &= (mysql_query("\n CREATE TABLE IF NOT EXISTS players_skills (\n f_pid MEDIUMINT SIGNED NOT NULL,\n f_skill_id SMALLINT UNSIGNED NOT NULL,\n type VARCHAR(1)\n )\n ") or die(mysql_error()));
$players = get_rows('players', array('player_id', 'ach_nor_skills', 'ach_dob_skills', 'extra_skills'), array('ach_nor_skills != "" OR ach_dob_skills != "" OR extra_skills != ""'));
foreach ($players as $p) {
foreach (array('N' => 'ach_nor_skills', 'D' => 'ach_dob_skills', 'E' => 'extra_skills') as $t => $grp) {
$values = empty($p->{$grp}) ? array() : array_map(create_function('$s', 'global $skillididx_rvs; return "(' . $p->player_id . ',\'' . $t . '\',".$skillididx_rvs[$s].")";'), explode(',', $p->{$grp}));
if (!empty($values)) {
$status &= (mysql_query("INSERT INTO players_skills(f_pid, type, f_skill_id) VALUES " . implode(',', $values)) or die(mysql_error()));
}
}
}
$sqls_drop = array(SQLUpgrade::runIfColumnExists('players', 'ach_nor_skills', 'ALTER TABLE players DROP ach_nor_skills'), SQLUpgrade::runIfColumnExists('players', 'ach_dob_skills', 'ALTER TABLE players DROP ach_dob_skills'), SQLUpgrade::runIfColumnExists('players', 'extra_skills', 'ALTER TABLE players DROP extra_skills'));
foreach ($sqls_drop as $query) {
$status &= (mysql_query($query) or die(mysql_error()));
}
return $status;
}
示例2: dumpTable
function dumpTable($table, $style, $is_view = false)
{
if ($_POST["format"] == "sql_alter") {
$create = create_sql($table, $_POST["auto_increment"]);
if ($is_view) {
echo substr_replace($create, " OR REPLACE", 6, 0) . ";\n\n";
} else {
echo substr_replace($create, " IF NOT EXISTS", 12, 0) . ";\n\n";
// create procedure which iterates over original columns and adds new and removes old
$query = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLLATION_NAME, COLUMN_TYPE, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . q($table) . " ORDER BY ORDINAL_POSITION";
echo "DELIMITER ;;\nCREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN\n\tDECLARE _column_name, _collation_name, after varchar(64) DEFAULT '';\n\tDECLARE _column_type, _column_default text;\n\tDECLARE _is_nullable char(3);\n\tDECLARE _extra varchar(30);\n\tDECLARE _column_comment varchar(255);\n\tDECLARE done, set_after bool DEFAULT 0;\n\tDECLARE add_columns text DEFAULT '";
$fields = array();
$after = "";
foreach (get_rows($query) as $row) {
$default = $row["COLUMN_DEFAULT"];
$row["default"] = $default !== null ? q($default) : "NULL";
$row["after"] = q($after);
//! rgt AFTER lft, lft AFTER id doesn't work
$row["alter"] = escape_string(idf_escape($row["COLUMN_NAME"]) . " {$row['COLUMN_TYPE']}" . ($row["COLLATION_NAME"] ? " COLLATE {$row['COLLATION_NAME']}" : "") . ($default !== null ? " DEFAULT " . ($default == "CURRENT_TIMESTAMP" ? $default : $row["default"]) : "") . ($row["IS_NULLABLE"] == "YES" ? "" : " NOT NULL") . ($row["EXTRA"] ? " {$row['EXTRA']}" : "") . ($row["COLUMN_COMMENT"] ? " COMMENT " . q($row["COLUMN_COMMENT"]) : "") . ($after ? " AFTER " . idf_escape($after) : " FIRST"));
echo ", ADD {$row['alter']}";
$fields[] = $row;
$after = $row["COLUMN_NAME"];
}
echo "';\n\tDECLARE columns CURSOR FOR {$query};\n\tDECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;\n\tSET @alter_table = '';\n\tOPEN columns;\n\tREPEAT\n\t\tFETCH columns INTO _column_name, _column_default, _is_nullable, _collation_name, _column_type, _extra, _column_comment;\n\t\tIF NOT done THEN\n\t\t\tSET set_after = 1;\n\t\t\tCASE _column_name";
foreach ($fields as $row) {
echo "\n\t\t\t\tWHEN " . q($row["COLUMN_NAME"]) . " THEN\n\t\t\t\t\tSET add_columns = REPLACE(add_columns, ', ADD {$row['alter']}', IF(\n\t\t\t\t\t\t_column_default <=> {$row['default']} AND _is_nullable = '{$row['IS_NULLABLE']}' AND _collation_name <=> " . (isset($row["COLLATION_NAME"]) ? "'{$row['COLLATION_NAME']}'" : "NULL") . " AND _column_type = " . q($row["COLUMN_TYPE"]) . " AND _extra = '{$row['EXTRA']}' AND _column_comment = " . q($row["COLUMN_COMMENT"]) . " AND after = {$row['after']}\n\t\t\t\t\t, '', ', MODIFY {$row['alter']}'));";
//! don't replace in comment
}
echo "\n\t\t\t\tELSE\n\t\t\t\t\tSET @alter_table = CONCAT(@alter_table, ', DROP ', '`', REPLACE(_column_name, '`', '``'), '`');\n\t\t\t\t\tSET set_after = 0;\n\t\t\tEND CASE;\n\t\t\tIF set_after THEN\n\t\t\t\tSET after = _column_name;\n\t\t\tEND IF;\n\t\tEND IF;\n\tUNTIL done END REPEAT;\n\tCLOSE columns;\n\tIF @alter_table != '' OR add_columns != '' THEN\n\t\tSET alter_command = CONCAT(alter_command, 'ALTER TABLE " . adminer_table($table) . "', SUBSTR(CONCAT(add_columns, @alter_table), 2), ';\\n');\n\tEND IF;\nEND;;\nDELIMITER ;\nCALL adminer_alter(@adminer_alter);\nDROP PROCEDURE adminer_alter;\n\n";
//! indexes
}
return true;
}
}
示例3: get_rows
//номер специальности
if (!isset($id_e)) {
//список отделений
$sql = "SELECT * FROM osakond ORDER BY name_osakond ASC";
} else {
$sql = "SELECT * FROM eriala WHERE id_eriala=" . $id_e;
}
$rows = get_rows($sql);
echo '<div id="column3"><h1>Osakond</h1>
<div style="width:912px;">';
if (isset($id_e)) {
foreach ($rows as $row) {
echo '<div id="column2" style="min-height:250px; height:100%;"><h2>' . $row[1] . '</h2>
<span class="left"><img src="images/' . $row[2] . '" alt="" width="148px" height="168px"></span>
<p style="width: 800px">' . $row[4] . '</p>
</div> ';
echo '<a href="' . $_SERVER['PHP_SELF'] . "?page=" . $page . '">Tagasi</a>';
}
} else {
foreach ($rows as $row) {
echo '<h2>' . $row[1] . '</h2>';
$sql_e = "SELECT * FROM eriala WHERE id_osakond=" . $row[0];
$rows_e = get_rows($sql_e);
$text = "";
foreach ($rows_e as $row_e) {
$text .= "<li> <a href='" . $_SERVER['PHP_SELF'] . "?page=" . $page . "&id_e=" . $row_e[0] . "'>" . $row_e[1] . "</a></li>";
}
echo '<ul>' . $text . '</ul>';
}
}
echo '</div></div>';
示例4: array
<?php
$USER = $_GET["user"];
$privileges = array("" => array("All privileges" => ""));
foreach (get_rows("SHOW PRIVILEGES") as $row) {
foreach (explode(",", $row["Privilege"] == "Grant option" ? "" : $row["Context"]) as $context) {
$privileges[$context][$row["Privilege"]] = $row["Comment"];
}
}
$privileges["Server Admin"] += $privileges["File access on server"];
$privileges["Databases"]["Create routine"] = $privileges["Procedures"]["Create routine"];
// MySQL bug #30305
unset($privileges["Procedures"]["Create routine"]);
$privileges["Columns"] = array();
foreach (array("Select", "Insert", "Update", "References") as $val) {
$privileges["Columns"][$val] = $privileges["Tables"][$val];
}
unset($privileges["Server Admin"]["Usage"]);
foreach ($privileges["Tables"] as $key => $val) {
unset($privileges["Databases"][$key]);
}
$new_grants = array();
if ($_POST) {
foreach ($_POST["objects"] as $key => $val) {
$new_grants[$val] = (array) $new_grants[$val] + (array) $_POST["grants"][$key];
}
}
$grants = array();
$old_pass = "";
if (isset($_GET["host"]) && ($result = $connection->query("SHOW GRANTS FOR " . q($USER) . "@" . q($_GET["host"])))) {
//! use information_schema for MySQL 5 - column names in column privileges are not escaped
示例5: connect
include "./func.php";
try {
$conn = connect();
} catch (Exception $error) {
display_message($error->getMessage(), "", "error");
exit;
}
$nickname = get_nickname($conn);
//获取页面参数
if (isset($_GET['page']) && is_num($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
$PAGESIZE = 5;
$pages = ceil(get_rows($conn) / $PAGESIZE);
$offset = $PAGESIZE * ($page - 1);
$select = "select * from article order by id desc limit {$offset},{$PAGESIZE}";
$result = $conn->query($select);
?>
<!DOCTYPE html>
<html>
<head>
<title>monogatari</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-combined.min.css">
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
示例6: db_init
<?php
include_once 'cgi/config.php';
include_once 'cgi/common.php';
db_init();
$samples = get_rows('samples');
?>
<html lang="en">
<head>
<title>Data Generator App!</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet" >
<link href="css/themes/<?php
echo $theme;
?>
.css" rel="stylesheet" >
</head>
<body>
<div class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a href="/" class="navbar-brand">Data Generator App!!!</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="navbar-main">
示例7: foreach
<div class="boxCommon">
<div class="boxTitle<?php
echo T_HTMLBOX_ADMIN;
?>
">
Change local access level
</div>
<div class="boxBody">
<form method="POST">
Coach name<br> <input type="text" name="cname" id="coach1" size="20" maxlength="50"><br><br>
<div id='massuserlist' style='display:none;'>
Coaches<br>
<br>
<?php
foreach (get_rows('coaches', array('coach_id', 'name')) as $subm_coach) {
echo "<input type='checkbox' name='cid{$subm_coach->coach_id}' value='1'> {$subm_coach->name}<br>\n";
}
?>
<br>
</div>
Access level<br>
<select name="ring">
<?php
foreach ($T_LOCAL_RINGS as $r => $desc) {
echo "<option value='{$r}' " . ($r == Coach::T_RING_LOCAL_REGULAR ? 'SELECTED' : '') . ">{$desc}</option>\n";
}
echo "<option value='" . Coach::T_RING_LOCAL_NONE . "'>None</option>\n";
?>
</select>
<br><br>
示例8: getWonTours
public function getWonTours()
{
// Returns an array of tournament objects for those tournaments this team has won.
return array_map(create_function('$t', 'return new Tour($t->tour_id);'), get_rows('tours', array('tour_id'), array("winner = {$this->team_id}")));
}
示例9: array
$EVENT = $_GET["event"];
$intervals = array("YEAR", "QUARTER", "MONTH", "DAY", "HOUR", "MINUTE", "WEEK", "SECOND", "YEAR_MONTH", "DAY_HOUR", "DAY_MINUTE", "DAY_SECOND", "HOUR_MINUTE", "HOUR_SECOND", "MINUTE_SECOND");
$statuses = array("ENABLED" => "ENABLE", "DISABLED" => "DISABLE", "SLAVESIDE_DISABLED" => "DISABLE ON SLAVE");
$row = $_POST;
if ($_POST && !$error) {
if ($_POST["drop"]) {
query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.'));
} elseif (in_array($row["INTERVAL_FIELD"], $intervals) && isset($statuses[$row["STATUS"]])) {
$schedule = "\nON SCHEDULE " . ($row["INTERVAL_VALUE"] ? "EVERY " . q($row["INTERVAL_VALUE"]) . " {$row['INTERVAL_FIELD']}" . ($row["STARTS"] ? " STARTS " . q($row["STARTS"]) : "") . ($row["ENDS"] ? " ENDS " . q($row["ENDS"]) : "") : "AT " . q($row["STARTS"])) . " ON COMPLETION" . ($row["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE";
queries_redirect(substr(ME, 0, -1), $EVENT != "" ? lang('Event has been altered.') : lang('Event has been created.'), queries(($EVENT != "" ? "ALTER EVENT " . idf_escape($EVENT) . $schedule . ($EVENT != $row["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($row["EVENT_NAME"]) : "") : "CREATE EVENT " . idf_escape($row["EVENT_NAME"]) . $schedule) . "\n" . $statuses[$row["STATUS"]] . " COMMENT " . q($row["EVENT_COMMENT"]) . rtrim(" DO\n{$row['EVENT_DEFINITION']}", ";") . ";"));
}
}
page_header($EVENT != "" ? lang('Alter event') . ": " . h($EVENT) : lang('Create event'), $error);
if (!$row && $EVENT != "") {
$rows = get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . q(DB) . " AND EVENT_NAME = " . q($EVENT));
$row = reset($rows);
}
?>
<form action="" method="post">
<table cellspacing="0">
<tr><th><?php
echo lang('Name');
?>
<td><input name="EVENT_NAME" value="<?php
echo h($row["EVENT_NAME"]);
?>
" maxlength="64" autocapitalize="off">
<tr><th title="datetime"><?php
echo lang('Start');
示例10: getTestTeams
function getTestTeams()
{
$sql = "SELECT * FROM testsolve_team";
return get_rows($sql);
}
示例11: getTestCommentsAll
function getTestCommentsAll()
{
$sql = sprintf("SELECT comments.id, comments.uid, comments.comment, comments.type,\n comments.timestamp, comments.pid, comment_type.name FROM\n comments LEFT JOIN comment_type ON comments.type=comment_type.id\n WHERE comment_type.name='Testsolver' ORDER BY comments.id ASC", mysql_real_escape_string($pid));
return get_rows($sql);
}
示例12: process_list
/** Get process list
* @return array ($row)
*/
function process_list()
{
return get_rows("SHOW FULL PROCESSLIST");
}
示例13: get_rows
<?php
//get number of page from db in tabel "menyy"
$sql = "SELECT * FROM menyy WHERE flag=2";
$rows = get_rows($sql);
foreach ($rows as $row) {
$page = $row[3];
$k = 1;
if ($k == 1) {
$sql_o = "SELECT * FROM osakond ORDER BY name_osakond ASC";
$rows_o = get_rows($sql_o);
$text = "";
foreach ($rows_o as $row_o) {
$text .= "<li> <a href='" . $_SERVER['PHP_SELF'] . "?page=" . $page . "&id_o=" . $row_o[0] . "'>" . $row_o[1] . "</a></li>";
}
echo "\t<div class='sidebaritem'>\n \t\t\t\t<div class='sbihead'>\n \t\t\t\t\t<h1>" . $row[1] . "</h1>\n \t\t\t\t</div>\n \t\t\t\t\t<div class='sbilinks'> \n \t\t\t\t\t<ul>";
echo $text;
echo "</ul></div></div>";
}
$k++;
}
示例14: foreach
}
foreach ($orig_fields as $field) {
$field["has_default"] = isset($field["default"]);
if ($field["on_update"]) {
$field["default"] .= " ON UPDATE {$field['on_update']}";
// CURRENT_TIMESTAMP
}
$row["fields"][] = $field;
}
if (support("partitioning")) {
$from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . q(DB) . " AND TABLE_NAME = " . q($TABLE);
$result = $connection->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION {$from} ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");
list($row["partition_by"], $row["partitions"], $row["partition"]) = $result->fetch_row();
$row["partition_names"] = array();
$row["partition_values"] = array();
foreach (get_rows("SELECT PARTITION_NAME, PARTITION_DESCRIPTION {$from} AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION") as $row1) {
$row["partition_names"][] = $row1["PARTITION_NAME"];
$row["partition_values"][] = $row1["PARTITION_DESCRIPTION"];
}
$row["partition_names"][] = "";
}
}
$collations = collations();
$suhosin = floor(extension_loaded("suhosin") ? (min(ini_get("suhosin.request.max_vars"), ini_get("suhosin.post.max_vars")) - 13) / 10 : 0);
// 10 - number of fields per row, 13 - number of other fields
if ($suhosin && count($row["fields"]) > $suhosin) {
echo "<p class='error'>" . h(lang('Maximum number of allowed fields exceeded. Please increase %s and %s.', 'suhosin.post.max_vars', 'suhosin.request.max_vars')) . "\n";
}
$engines = engines();
// case of engine may differ
foreach ($engines as $engine) {
示例15: foreach
$views[] = $table_status["Name"];
}
}
}
foreach ($views as $view) {
$adminer->dumpTable($view, $_POST["table_style"], true);
}
if ($ext == "tar") {
echo pack("x512");
}
}
if ($style == "CREATE+ALTER" && $is_sql) {
// drop old tables
$query = "SELECT TABLE_NAME, ENGINE, TABLE_COLLATION, TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE()";
echo "DELIMITER ;;\nCREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN\n\tDECLARE _table_name, _engine, _table_collation varchar(64);\n\tDECLARE _table_comment varchar(64);\n\tDECLARE done bool DEFAULT 0;\n\tDECLARE tables CURSOR FOR {$query};\n\tDECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;\n\tOPEN tables;\n\tREPEAT\n\t\tFETCH tables INTO _table_name, _engine, _table_collation, _table_comment;\n\t\tIF NOT done THEN\n\t\t\tCASE _table_name";
foreach (get_rows($query) as $row) {
$comment = q($row["ENGINE"] == "InnoDB" ? preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["TABLE_COMMENT"]) : $row["TABLE_COMMENT"]);
echo "\n\t\t\t\tWHEN " . q($row["TABLE_NAME"]) . " THEN\n\t\t\t\t\t" . (isset($row["ENGINE"]) ? "IF _engine != '{$row['ENGINE']}' OR _table_collation != '{$row['TABLE_COLLATION']}' OR _table_comment != {$comment} THEN\n\t\t\t\t\t\tALTER TABLE " . idf_escape($row["TABLE_NAME"]) . " ENGINE={$row['ENGINE']} COLLATE={$row['TABLE_COLLATION']} COMMENT={$comment};\n\t\t\t\t\tEND IF" : "BEGIN END") . ";";
}
echo "\n\t\t\t\tELSE\n\t\t\t\t\tSET alter_command = CONCAT(alter_command, 'DROP TABLE `', REPLACE(_table_name, '`', '``'), '`;\\n');\n\t\t\tEND CASE;\n\t\tEND IF;\n\tUNTIL done END REPEAT;\n\tCLOSE tables;\nEND;;\nDELIMITER ;\nCALL adminer_alter(@adminer_alter);\nDROP PROCEDURE adminer_alter;\n";
}
if (in_array("CREATE+ALTER", array($style, $_POST["table_style"])) && $is_sql) {
echo "SELECT @adminer_alter;\n";
}
}
}
if ($is_sql) {
echo "-- " . $connection->result("SELECT NOW()") . "\n";
}
exit;
}