本文整理汇总了PHP中Fetch函数的典型用法代码示例。如果您正苦于以下问题:PHP Fetch函数的具体用法?PHP Fetch怎么用?PHP Fetch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fetch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetNotifications
function GetNotifications()
{
global $loguserid, $NotifFormat;
$notifs = array();
if (!$loguserid) {
return $notifs;
}
// TODO do it better!
$staffnotif = '';
if (HasPermission('admin.viewstaffpms')) {
$staffnotif = ' OR user=-1';
}
$ndata = Query("SELECT type,id,date,args FROM {notifications} WHERE user={0}{$staffnotif} ORDER BY date DESC", $loguserid);
while ($n = Fetch($ndata)) {
$ncb = $NotifFormat[$n['type']];
if (function_exists($ncb)) {
$ndesc = $ncb($n['id'], $n['args'] ? unserialize($n['args']) : null);
} else {
$ndesc = htmlspecialchars($n['type'] . ':' . $n['id']);
}
$ts = '<span class="nobr">';
$te = '</span>';
$ndesc = $ts . str_replace("\n", $te . '<br>' . $ts, $ndesc) . $te;
$notifs[] = array('date' => $n['date'], 'formattedDate' => relativedate($n['date']), 'text' => $ndesc);
}
return $notifs;
}
示例2: getWikiPage
function getWikiPage($id, $rev = 0)
{
global $canedit, $canmod;
$ptitle = $id;
if (!$ptitle) {
$ptitle = 'Main_page';
} else {
$ptitle = title2url($ptitle);
}
// so that we don't have for example 'Main page' and 'Main_page' being considered different pages
if ($rev < 0) {
$rev = 0;
}
$page = Query("SELECT p.*, pt.date, pt.user, pt.text FROM {wiki_pages} p LEFT JOIN {wiki_pages_text} pt ON pt.id=p.id AND pt.revision=" . ($rev > 0 ? 'LEAST(p.revision,{1})' : 'p.revision') . " WHERE p.id={0}", $ptitle, $rev);
if (!NumRows($page)) {
$page = array('id' => $ptitle, 'revision' => 0, 'flags' => 0, 'text' => '', 'new' => 1);
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Fount');
} else {
$page = Fetch($page);
}
$page['istalk'] = strtolower(substr($ptitle, 0, 5)) == 'talk:';
$page['ismain'] = strtolower($ptitle) == 'main_page';
$page['canedit'] = $canedit && (!($page['flags'] & WIKI_PFLAG_SPECIAL) || HasPermission('wiki.makepagesspecial'));
return $page;
}
示例3: load
public static function load()
{
self::$settingsArray = array();
$rSettings = Query("select * from {settings}");
while ($setting = Fetch($rSettings)) {
self::$settingsArray[$setting['plugin']][$setting['name']] = $setting['value'];
}
}
示例4: loadSmiliesOrdered
function loadSmiliesOrdered()
{
global $smiliesOrdered;
$rSmilies = Query("select * from {smilies}");
$smilies = array();
while ($smiley = Fetch($rSmilies)) {
$smiliesOrdered[] = $smiley;
}
}
示例5: loadBlockLayouts
function loadBlockLayouts()
{
global $blocklayouts, $loguserid;
if (isset($blocklayouts)) {
return;
}
$rBlocks = Query("select * from {blockedlayouts} where blockee = {0}", $loguserid);
$blocklayouts = array();
while ($block = Fetch($rBlocks)) {
$blocklayouts[$block['user']] = 1;
}
}
示例6: MakeOptions
function MakeOptions($catid)
{
$sel[$catid] = " selected=\"true\"";
$qFora = "select id,name from categories";
$rFora = Query($qFora);
$result = "<select name=\"category\" size=\"1\">";
while ($forum = Fetch($rFora)) {
$result .= "<option value=\"" . $forum['id'] . "\"" . $sel[$forum['id']] . "\\>" . $forum['name'] . "</option>";
}
$result .= "</select>";
return $result;
}
示例7: isIPBanned
function isIPBanned($ip)
{
$rIPBan = Query("select * from {ipbans} where instr({0}, ip)=1", $ip);
while ($ipban = Fetch($rIPBan)) {
// check if this IP ban is actually good
// if the last character is a number, IPs have to match precisely
if (ctype_alnum(substr($ipban['ip'], -1)) && $ip !== $ipban['ip']) {
continue;
}
return $ipban;
}
return false;
}
示例8: ircForumPrefix
function ircForumPrefix($forum)
{
global $forumBoards;
$prefix = '';
if ($forum['board'] != '') {
$prefix = $forumBoards[$forum['board']] . ' > ';
}
$parents = Query("SELECT title FROM {forums} WHERE l<{0} AND r>{1} ORDER BY l", $forum['l'], $forum['r']);
while ($p = Fetch($parents)) {
$prefix .= $p['title'] . ' > ';
}
return $prefix;
}
示例9: loadSmilies
function loadSmilies()
{
global $smilies, $smiliesReplaceOrig, $smiliesReplaceNew;
$rSmilies = Query("select * from {smilies} order by length(code) desc");
$smilies = array();
while ($smiley = Fetch($rSmilies)) {
$smilies[] = $smiley;
}
$smiliesReplaceOrig = $smiliesReplaceNew = array();
for ($i = 0; $i < count($smilies); $i++) {
$smiliesReplaceOrig[] = "/(?<!\\w)" . preg_quote($smilies[$i]['code'], "/") . "(?!\\w)/";
$smiliesReplaceNew[] = "<img class=\"smiley\" alt=\"\" src=\"" . resourceLink("img/smilies/" . $smilies[$i]['image']) . "\" />";
}
}
示例10: CleanupUploads
function CleanupUploads()
{
$targetdir = DATA_DIR . 'uploads';
$timebeforedel = time() - 604800;
// one week
$todelete = Query("SELECT physicalname, user, filename FROM {uploadedfiles} WHERE deldate!=0 AND deldate<{0}", $timebeforedel);
if (NumRows($todelete)) {
while ($entry = Fetch($todelete)) {
Report("[b]{$entry['filename']}[/] deleted by auto-cleanup", false);
DeleteUpload($targetdir . '/' . $entry['physicalname'], $entry['user']);
}
Query("DELETE FROM {uploadedfiles} WHERE deldate!=0 AND deldate<{0}", $timebeforedel);
}
}
示例11: isIPBanned
function isIPBanned($ip)
{
$rIPBan = Query("select * from {ipbans} where instr({0}, ip)=1", $ip);
$result = false;
while ($ipban = Fetch($rIPBan)) {
if (IPMatches($ip, $ipban['ip'])) {
if ($ipban['whitelisted']) {
return false;
} else {
$result = $ipban;
}
}
}
return $result;
}
示例12: fixcoldata
function fixcoldata($table, $field, $key)
{
echo "fixing data in {$table}.{$field}...";
$data = Query("SELECT {$field},{$key} FROM {" . $table . "}");
while ($row = Fetch($data)) {
// data was UTF8 stored as latin1
// then latin1->UTF8
// resulting in double UTF8 encoding
// to fix, convert back to latin1
$blarg = $row[$field];
$blarg = utf8_decode($blarg);
Query("UPDATE {" . $table . "} SET {$field}={0} WHERE {$key}={1}", $blarg, $row[$key]);
}
echo " ok<br>";
}
示例13: cbv3_show_rating
/**
* Show-rating function for cbv3 template
*
*/
function cbv3_show_rating($rating)
{
$array = array();
if (error()) {
$array['err'] = error();
}
$array['rating'] = $rating;
$rated_by = $rating['ratings'];
$rating = $rating['rating'];
$rating_full = $rating * 10;
$likes = $rating_full * $rated_by / 100;
$likes = round($likes + 0.49, 0);
$dislikes = $rated_by - $likes;
assign('rating', array('rating' => $rating, 'dislikes' => $dislikes, 'likes' => $likes, 'rated_by' => $rated_by, 'rating_perc' => $rating_full));
$template = Fetch('blocks/rating.html');
$array['template'] = $template;
echo json_encode($array);
}
示例14: doThreadPreview
function doThreadPreview($tid)
{
global $mobileLayout;
if ($mobileLayout) {
return;
}
$rPosts = Query("\n\t\tselect\n\t\t\t{posts}.id, {posts}.date, {posts}.num, {posts}.deleted, {posts}.options, {posts}.mood, {posts}.ip,\n\t\t\t{posts_text}.text, {posts_text}.text, {posts_text}.revision,\n\t\t\tu.(_userfields)\n\t\tfrom {posts}\n\t\tleft join {posts_text} on {posts_text}.pid = {posts}.id and {posts_text}.revision = {posts}.currentrevision\n\t\tleft join {users} u on u.id = {posts}.user\n\t\twhere thread={0} and deleted=0\n\t\torder by date desc limit 0, 20", $tid);
if (NumRows($rPosts)) {
$posts = "";
while ($post = Fetch($rPosts)) {
$cellClass = ($cellClass + 1) % 2;
$poster = getDataPrefix($post, "u_");
$nosm = $post['options'] & 2;
$nobr = $post['options'] & 4;
$posts .= Format("\n\t\t\t<tr>\n\t\t\t\t<td class=\"cell2\" style=\"width: 15%; vertical-align: top;\">\n\t\t\t\t\t{1}\n\t\t\t\t</td>\n\t\t\t\t<td class=\"cell{0}\">\n\t\t\t\t\t<button style=\"float: right;\" onclick=\"insertQuote({2});\">" . __("Quote") . "</button>\n\t\t\t\t\t<button style=\"float: right;\" onclick=\"insertChanLink({2});\">" . __("Link") . "</button>\n\t\t\t\t\t{3}\n\t\t\t\t</td>\n\t\t\t</tr>\n\t", $cellClass, UserLink($poster), $post['id'], CleanUpPost($post['text'], $poster['name'], $nosm));
}
Write("\n\t\t<table class=\"outline margin\">\n\t\t\t<tr class=\"header0\">\n\t\t\t\t<th colspan=\"2\">" . __("Thread review") . "</th>\n\t\t\t</tr>\n\t\t\t{0}\n\t\t</table>\n\t", $posts);
}
}
示例15: getBirthdaysText
function getBirthdaysText()
{
$rBirthdays = Query("select u.birthday, u.(_userfields) from {users} u where birthday > 0 and powerlevel >= 0 order by name");
$birthdays = array();
while ($user = Fetch($rBirthdays)) {
$b = $user['birthday'];
if (gmdate("m-d", $b) == gmdate("m-d")) {
$y = gmdate("Y") - gmdate("Y", $b);
$birthdays[] = UserLink(getDataPrefix($user, "u_")) . " (" . $y . ")";
}
}
if (count($birthdays)) {
$birthdaysToday = implode(", ", $birthdays);
}
if ($birthdaysToday) {
return "<br>" . __("Birthdays today:") . " " . $birthdaysToday;
} else {
return "";
}
}