本文整理汇总了PHP中sql::fetch_array方法的典型用法代码示例。如果您正苦于以下问题:PHP sql::fetch_array方法的具体用法?PHP sql::fetch_array怎么用?PHP sql::fetch_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql
的用法示例。
在下文中一共展示了sql::fetch_array方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: content
function content()
{
$db = new sql();
$db->connect();
if (time() < 1098388800) {
$res = $db->query("select projects.id, name, company, category, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM projects left join votes on projects.id=votes.id group by projects.id, name, company, category order by gsum desc");
} else {
$res = $db->query("select projects.id, name, company, category, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM projects left join votes on projects.id=votes.id where grade>0 group by projects.id, name, company, category order by gsum desc");
}
$cats = array(1 => "A", "C", "Y");
$tr = "";
while ($data = $db->fetch_array($res)) {
$res1 = $db->query("select * from categories where category_id={$data['category']}");
$data1 = $db->fetch_array($res1);
$url = "/projects/" . $cats[$data1["category_id"]] . "/";
eval('$tr.="' . page::template("modules/resultTR") . '";');
}
if (!$tr) {
$tr = "<p style=\"font-size: 0.85em;\">В настоящее время в данной номинации заявок не подано.</p><p style=\"font-size: 0.85em;\"><a href=\"/request/\">Заявки</a> принимаются до 15 октября 2004 года</p>";
}
$resultTr .= $tr;
if ($resultTr) {
eval('$projectsMain.="' . page::template("modules/resultMain") . '";');
}
$resultTr = "";
if (time() < 1098388800) {
$text = "<p>Здесь размещены текущие результаты голосования, обновляющиеся в режиме реального времени.</p><p>Для того, чтобы проголосовать за проект надо перейти на его страницу.</p><p>Вы можете поставить свою оценку каждому из 22 представленных проектов, но можете сделать это только 1 раз за весь период голосования.</p><p>Голосование открыто до 0:00 22 октября 2004 года.</p>";
} else {
$text = "<h3>Голование закрыто в 0:00 22 октября 2004 года.</h3><p><i>При анализе хода голосования за проекты в интернете, Оргкомитет конкурса М2. Новый Дом 2004. обнаружил многочисленные случаи злоупотребления при выставлении оценки 0 баллов. В целях повышения релевантности итогов голосования, Оргкомитет принял решение не учитывать оценки 0 баллов, выставленные за весь период голосования в интернете.</i></p>";
}
$this->elements["content"] = $text . $projectsMain;
}
示例2: defaultAction
function defaultAction()
{
global $HTTP_SERVER_VARS;
include "./lib/config.inc.php";
$db = new sql();
$db->connect();
$result = $db->query('SELECT VERSION() AS version');
if ($result != FALSE && $db->num_rows($result) > 0) {
$row = $db->fetch_array($result);
$match = $row['version'];
} else {
$result = $db->query('SHOW VARIABLES LIKE \'version\'');
if ($result != FALSE && $db->num_rows($result) > 0) {
$row = $db->fetch_array($result);
$match = $row[1];
}
}
$this->MYSQL_VER = $match;
$this->PHP_OS = PHP_OS;
$this->PHP_VERSION = PHP_VERSION;
$this->CMS = $admin_config["name"] . " " . $admin_config["version"];
$this->AUTHOR = $admin_config["author"];
$this->HOME_PAGE = $admin_config["home_page"];
$content = admin::template("info", $this);
$this->elements["content"] = $content;
}
示例3: event_CreateRevision
function event_CreateRevision(&$data)
{
$res = sql::query("\r\n\t\t\t\tSELECT \r\n\t\t\t\t\t*\r\n\t\t\t\tFROM \r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_seo\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tID = '" . $data['id'] . "' AND\r\n\t\t\t\t\trevision = '" . $data['from'] . "'\r\n\t\t\t");
while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
sql::query("\r\n\t\t\t\t\tINSERT INTO \r\n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_seo \r\n\t\t\t\t\tSET \r\n\t\t\t\t\t\tID='" . $data['id'] . "', \r\n\t\t\t\t\t\trevision='" . $data['to'] . "',\r\n\t\t\t\t\t\tkeywords='" . addslashes($row['keywords']) . "',\r\n\t\t\t\t\t\tdescription='" . addslashes($row['description']) . "'\r\n\t\t\t\t");
}
}
示例4: language
function language($language, $site, $load = false)
{
$res = sql::query("\r\n\t\t \tSELECT \r\n\t\t\t\t *\r\n\t\t\t FROM\r\n \t\t\t\t" . _TABLE_PREFIX_ . "language\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tid = '" . addslashes($language) . "' AND\r\n\t\t\t\t\tsite = '" . addslashes($site) . "'\r\n\t\t ");
if ($row = sql::fetch_array($res)) {
$this->id = $row['id'];
$this->name = $row['name'];
$this->public = !!$row['public'];
} else {
$this->id = 'en';
$this->name = 'English';
$this->public = false;
}
@(include _BASE_LIBRARIES_ . 'resources/iso639to3166.php');
$this->flag = strtolower($iso639to3166[$this->id]);
if ($load) {
// Load english strings first...
$res = @mysql_query("\r\n\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t* \r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "strings\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tlanguage = 'en'\r\n\t\t\t\t");
while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
$this->strings[$row['id']] = $row['value'];
}
if ($language != 'en') {
$res = sql::query("\r\n\t\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t\t* \r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "strings\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\tlanguage = '" . addslashes($language) . "'\r\n\t\t\t\t\t");
while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
$this->strings[$row['id']] = $row['value'];
}
}
}
}
示例5: get_tree
function get_tree($id = 0, $open_nodes, $level = 0, $url = "")
{
global $cid;
$furl = $url;
$level++;
$style = $level == 1 ? " style=\"margin-left: 0px; padding-left: 0px;\"" : "";
$db = new sql();
$db->connect();
$res = $db->query(_QUERY . " where pid={$id} order by sortorder");
if ($db->num_rows($res) > 0) {
$s .= "<ul{$style}>\n";
while ($data = $db->fetch_array($res)) {
$gc = got_child($data["id"]);
$img = $gc ? $open_nodes[$data["id"]] ? "minus" : "plus" : "dot";
$img1 = $gc ? $open_nodes[$data["id"]] ? "folderopen" : "folder" : "page";
$pid = $open_nodes[$data["id"]] ? $data["pid"] : $data["id"];
$checked = $data["id"] == $cid ? " checked" : "";
$url .= "/" . $data["url"];
$a_o = $gc ? "<a href=\"?id={$pid}\" class=\"{$class}\" id=\"tree\">" : "";
$a_c = $gc ? "</a>" : "";
$s .= "<li>{$a_o}<img src=\"../i/" . $img . ".gif\" alt=\"\" border=\"0\" align=\"absmiddle\" height=\"20\" width=\"20\" style=\"margin: 3px;\"><input type=\"radio\" name=\"sel\" id =\"sel\" value=\"" . $url . "/\" align=\"middle\" style=\"border-width: 0px\" onClick=\"onSelect()\"{$checked}><img src=\"../i/{$img1}.gif\" alt=\"\" border=\"0\" align=\"absmiddle\" height=\"20\" width=\"20\" style=\"margin: 3px;\"><span id=\"name" . $data["id"] . "\">" . $data["title"] . "</span>{$a_c}</li>\n";
if ($open_nodes[$data["id"]]) {
$s .= get_tree($data["id"], $open_nodes, $level, $url);
} else {
$url = $furl;
}
}
$s .= "</ul>\n";
return $s;
} else {
return;
}
}
示例6: defaultAction
function defaultAction()
{
$db = new sql();
$db->connect();
$chid = $this->chid;
include "lib/pagination.class.php";
include "lib/orderby.class.php";
$adminConfig = admin::adminConfig();
for ($i = 1; $i < 4; $i++) {
$voteTR = "";
$orderBy = new orderBy("?chid=" . $this->chid . "&", array("id" => "№", "time" => "Дата", "name" => "Заголовок", "company" => "Компания", "gsum" => "Средний бал", "gcount" => "Проголосовало"), array("gsum" => "desc"), $this->field[$i], $this->order[$i], array("field[{$i}]", "order[{$i}]"));
$pagination = new pagination($orderBy->urlForPage(), $this->page, $adminConfig["recPerPage"], '', "projects", "id");
$res = $db->query("select projects.id, name, company, category_name, date, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM (projects LEFT JOIN categories ON projects.category = categories.category_id) left join votes on projects.id=votes.id where category={$i} group by projects.id, name, company, category_name, date " . $orderBy->orderByQuery() . " " . $pagination->limit());
$page = $this->page ? "&page=" . $this->page : "";
while ($data = $db->fetch_array($res)) {
$data["date"] = date("d.m.Y", $data["date"]);
eval('$voteTR.="' . admin::template("voteTR") . '";');
}
$pageBar = $pagination->bar();
$th = $orderBy->bar();
eval('$content.="' . admin::template("voteMain") . '";');
$content .= "<br>";
}
$this->elements["content"] = $content;
}
示例7: read
function read()
{
$res = sql::query('SELECT * FROM ' . _TABLE_PREFIX_ . 'config');
while ($row = sql::fetch_array($res)) {
$this->data[$row['name']] = unserialize($row['data']);
}
}
示例8: _changeLanguage
function _changeLanguage($id, $language)
{
$res = sql::query("\r\n\t\t\t\tUPDATE \r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\tSET \r\n\t\t\t\t\tlanguage = '" . addslashes($language) . "'\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tID='" . $id . "'\r\n\t\t\t");
$res = sql::query("\r\n\t\t\t\tSELECT \r\n\t\t\t\t\t*\r\n\t\t\t\tFROM \r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tparent = '" . $id . "'\r\n\t\t\t");
while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
$this->_changeLanguage($row['ID'], $language);
}
}
示例9: authorize
function authorize($ticket)
{
ticket::cleanup();
$res = sql::query("\r\n\t\t\t\tSELECT \r\n\t\t\t\t\t* \r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "tickets\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tticket = '" . addslashes($ticket) . "'\r\n\t\t\t");
if ($row = sql::fetch_array($res)) {
return $row['id'];
}
}
示例10: rightBar
function rightBar()
{
$db = new sql();
$db->connect();
$res = $db->query(" select * from news order by time desc limit 0, 3");
while ($data = $db->fetch_array($res)) {
$this->elements["rightBar"] .= '<table><tr><th>' . $data["title"] . ':</th></tr><tr><td>' . $data["text"] . '</td></tr></table>';
}
$this->elements["rightBar"] = '<td valign="top" style="padding-left: 1em;">' . $this->elements["rightBar"] . '<p align="right"><a href="/news/">¬се новости →</a></p><br><i>¬ принципе, вы можете зайти и ознакомитьс¤ с <a href="/timeline/" target="_self">хронологией моих работ</a> (благо, их пока не так уж много).</i><p align="right"><a href="/card/" target="_self"> арта сайта →</a></p></td>';
}
示例11: edit
function edit()
{
$db = new sql();
$db->connect();
$res = $db->query("select * from news where id=" . $this->id);
$data = $db->fetch_array($res);
$data["text"] = htmlspecialchars($data["text"]);
$select = admin::getDateSelectOptions($data["time"]);
$chid = $this->chid;
$action = "appendEdit";
$header = "Редактирование";
eval("\$content=\"" . admin::template("newsAdd", "FORMPOST", array("fields[title]" => "EXISTS")) . "\";");
$this->elements["content"] = $content;
}
示例12: pagination
function pagination($curUrl, $curPage, $recPerPage, $totalCount, $tableName = "", $fieldName = "", $where = "")
{
$this->url = $curUrl;
$this->page = $curPage ? $curPage : 1;
$this->recPerPage = $recPerPage;
if ($totalCount) {
$this->totalRecCount = $totlaCount;
} else {
$db = new sql();
$db->connect();
$db->query("select count({$fieldName}) as rec_count from {$tableName} {$where}");
$data = $db->fetch_array($db->result);
$this->totalRecCount = $data["rec_count"];
}
}
示例13: edit
function edit()
{
$db = new sql();
$db->connect();
$res = $db->query("select * from projects where id=" . $this->id);
$data = $db->fetch_array($res);
$data["date"] = date("d.m.Y", $data["date"]);
//$data["end"]=date("d.m.Y", $data["end"]);
$category_selected[$data["category"]] = " selected";
$chid = $this->chid;
$action = "appendEdit";
$header = "Редактирование";
eval("\$content=\"" . admin::template("projectsAdd", "FORMPOST", array("fields[url]" => "EXISTS", "fields[title]" => "EXISTS")) . "\";");
$this->elements["content"] = $content;
}
示例14: edit
function edit()
{
$db = new sql();
$db->connect();
$res = $db->query("select * from users where id=" . $this->id);
$data = $db->fetch_array($res);
$data["description"] = htmlspecialchars($data["description"]);
$chid = $this->chid;
$action = "appendEdit";
$id = '<tr>
<td>№</td>
<td><input maxlength="14" name="fields[id]" size="14" value="' . $this->id . '" readonly="readonly" style="width: auto;" value="' . $this->id . '"></td>
</tr>';
$header = "Редактирование";
eval("\$content=\"" . admin::template("usersEdit", "FORMPOST", array("fields[login]" => "EXISTS", "fields[name]" => "EXISTS", "confirm" => "EQUAL fields[pass]", "fields[email]" => "EMAIL")) . "\";");
$this->elements["content"] = $content;
}
示例15: _deleteItem
function _deleteItem($id)
{
global $manager;
/* Delete pages recursively */
$res = sql::query("\r\n\t\t\t\tSELECT \r\n\t\t\t\t\t*\r\n\t\t\t\tFROM \r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tparent = '" . $id . "'\r\n\t\t\t");
while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
$this->_deleteItem($row['ID']);
}
/* Delete the plugin data */
$delete = array('id' => $id);
$manager->handleEvent('DeleteItem', $delete);
/* Delete the revision history */
revisions::doDeletePage($id);
/* Delete */
treeStorage::startTransaction();
treeStorage::prepareForDelete($id);
$res = sql::query("\r\n\t\t\t\tDELETE FROM\r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tID='" . $id . "'\r\n\t\t\t");
treeStorage::stopTransaction();
}