本文整理汇总了PHP中sql::num_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP sql::num_rows方法的具体用法?PHP sql::num_rows怎么用?PHP sql::num_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql
的用法示例。
在下文中一共展示了sql::num_rows方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: got_child
function got_child($id)
{
$db = new sql();
$db->connect();
$res = $db->query(_QUERY . " where pid={$id}");
if ($db->num_rows($res) > 0) {
return true;
exit;
} else {
return false;
exit;
}
}
示例3: sql
function _sel($id = 0, $url = "", $menu = 0)
{
$db = new sql();
$db->connect();
if ($menu == 1) {
$where = " and menu=1";
} else {
$where = " and menu!=1";
}
$res = $db->query("select id, title, url from chapters where (pid={$id} and url<>'searchresult' and url<>'sitemap' and type<>4 and id<>1){$where} order by sortorder");
if ($db->num_rows($res) > 0) {
$sel = "<ul>";
while ($data = $db->fetch_array($res)) {
$str .= $data["title"];
$url1 = $url . "/" . $data["url"];
$sel .= "<li type=\"disc\"><a href=\"{$url1}/\">" . $data["title"] . "</a>\n";
$sel .= $this->_sel($data["id"], $url1);
$sel .= "</li>\n";
}
$sel .= "</ul>";
return $sel;
}
}
示例4: sql
function _got_child($id)
{
$db = new sql();
$db->connect();
$res = $db->query("select id, pid, title, LENGTH(text) as bl, url from chapters where pid={$id}");
return $db->num_rows($res) > 0;
}
示例5: HasScreen
public function HasScreen($id)
{
$cfg = new config();
$sql = new sql();
$query = $sql->exe($cfg->get("realmd"), "SELECT 1 FROM `bt_screen` WHERE `entry` = '" . $id . "'");
return $sql->num_rows($query) > 0 ? true : false;
}
示例6: DateTime
do something ... during error / message:
$sdl->log('...');
best also - before, so it's apart from the other messages, also: $sdl->log('- this was not true');
$sdl->finish_job('Mine Job'); // terminates the timer
*/
// ########################################################################################
// ########################################################################################
$sdl->start_job('Extra-Optimal Range Upgrade Planet Step');
$threshold = new DateTime('now');
date_sub($threshold, date_interval_create_from_date_string("45 days"));
$uts_threshold = date_format($threshold, 'U');
$sql = 'UPDATE planets SET planet_available_points = 677 WHERE planet_available_points = 320 AND planet_owner > 10 AND planet_owned_date < ' . $uts_threshold;
$db->query($sql);
$res = $db->num_rows();
if ($res > 0) {
$sdl->log('Extra-Optimal Range Upgrade Planet this time: ' . $res);
}
$sdl->finish_job('Extra-Optimal Range Upgrade Planet Step');
// ########################################################################################
// ########################################################################################
// Building Scheduler
$sdl->start_job('Building Scheduler');
$sql = 'SELECT planet_id,installation_type
FROM scheduler_instbuild
WHERE build_finish <= ' . $ACTUAL_TICK;
if (($q_inst = $db->query($sql)) === false) {
$sdl->log('<b>Error:</b> Could not query scheduler instbuild data! - SKIPPED');
} else {
if ($db->num_rows() > 0) {
示例7: FROM
} else {
// Now select all the queued buildings in the system
$sql = 'SELECT s.*,u.user_race,
p.planet_type,p.research_4,p.building_queue,
p.building_1,p.building_2,p.building_3,p.building_4,
p.building_5,p.building_6,p.building_7,p.building_8,
p.building_9,p.building_10,p.building_11,p.building_12
FROM (`scheduler_instbuild` s)
LEFT JOIN (planets p) ON s.planet_id = p.planet_id
LEFT JOIN (user u) ON u.user_id=p.planet_owner
WHERE p.building_queue <> 0';
//echo "First query:\n".$sql."\n";
if (($q_inst = $db->query($sql)) === false) {
echo "Error: could not query scheduler instbuild data!\n";
} else {
if ($db->num_rows() > 0) {
$n_instbuild = 0;
while ($build = $db->fetchrow($q_inst)) {
$building_name = 'building_' . ($build['installation_type'] + 1);
echo "Building being built : " . $build['installation_type'] . " (name: " . $building_name . ") Level: " . $build[$building_name] . "\n";
echo "Building will be built: " . ($build['building_queue'] - 1) . "\n";
// In order to calculate times correctly, I need to consider also the building
// being built at the moment
if ($build['installation_type'] == $build['building_queue'] - 1) {
$build[$building_name]++;
echo "New level: " . $build[$building_name] . "\n";
}
$time = GetBuildingTimeTicks($build['building_queue'] - 1, $build, $build['user_race']);
// Insert the queued building using the new method
$sql = 'INSERT INTO scheduler_instbuild (installation_type,planet_id,build_start,build_finish)
VALUES ("' . ($build['building_queue'] - 1) . '",
示例8: display_lastposts
/**
* Function to retrieve the latest posts from the forums
*/
function display_lastposts()
{
global $game, $config;
$dir = $config['forum_path'];
$limit = $config['forum_show'];
$f_url = $config['forum_url'];
if ($limit == 0) {
return;
}
include $_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/conf_global.php";
// Database connection
$fdb = new sql($INFO['sql_host'], $INFO['sql_database'], $INFO['sql_user'], $INFO['sql_pass']);
// create sql-object for db-connection
// Filtered query
$qr = $fdb->query("SELECT t.title as t_title, " . "t.starter_id as t_starter, " . "t.starter_name as t_starter_n, " . "t.forum_id as forumid, " . "FROM_UNIXTIME((t.start_date), '%d.%m.%y') as start_d, " . "t.posts as t_posts, " . "t.tid as t_id, " . "t.last_post as t_last_posted, " . "t.last_poster_id as t_last, " . "t.last_poster_name as t_name, " . "p.post as p_post, " . "g.g_title " . "FROM nonsolotaku_topics t, " . "nonsolotaku_posts p, " . "nonsolotaku_members m, " . "nonsolotaku_groups g " . "WHERE topic_id=tid && " . "new_topic=1 && " . "m.member_id=t.starter_id && " . "m.member_group_id=g.g_id && " . "t.approved=1 && " . "t.forum_id<>'15' && " . "t.forum_id<>'37' && " . "t.forum_id<>'12' " . "ORDER BY t_last_posted DESC " . "LIMIT 0, " . $limit);
$game->out('
<table class="style_outer" border="0" cellpadding="2" cellspacing="2" width="100%">
<tr>
<td align="center"><span class="sub_caption">' . constant($game->sprache("TEXT18")) . '</span><br><br>
<table border="0" cellpadding="5" cellspacing="5" width="100%" class="style_inner">
');
// calculating the number of replies
$nrows = $fdb->num_rows($qr);
for ($i = 0; $i < $nrows; $i++) {
$row = $fdb->fetchrow($qr);
$author_id = $row['t_starter'];
$author = $row['t_starter_n'];
$topic_title = $row['t_title'];
$topic_id = $row['t_id'];
$num_posts = $row['t_posts'];
$last_author = $row['t_name'];
$last_id = $row['t_last'];
$creation_date = $row['start_d'];
// Date and hour of last post
$posttime = strftime("%d/%m/%y, %H:%M", $row['t_last_posted']);
$game->out('
<tr>
<td valign="top">
<a href="' . $f_url . '?showtopic=' . $topic_id . '&view=getnewpost" target=_blank><span class="text_large">' . $topic_title . '</span></a><br>
<b>' . constant($game->sprache("TEXT19")) . '</b> <a href="' . $f_url . '?showuser=' . $author_id . '" target=_blank>' . $author . '</a><br/>
<b>' . constant($game->sprache("TEXT20")) . '</b> ' . $num_posts . '<br>
<b>' . constant($game->sprache("TEXT21")) . '</b> <a href="' . $f_url . '?showuser=' . $last_id . '" target=_blank>' . $last_author . '</a><br>
<b>' . constant($game->sprache("TEXT22")) . '</b> ' . $posttime . '
</td>
</tr>');
}
$game->out('
</table>
</td>
</tr>
</table>
');
$fdb->close();
}
示例9: unset
fputs($socket, "GET /subscribe/news.asp HTTP/1.0\nHOST: m-2.m-2.ru\n\n");
while (fgets($socket, 31337) != "\r\n" && !feof($socket)) {
unset($buffer);
}
include "/www/vhosts/award.m-2.ru/adm/lib/htmlcleaner.php";
include "/www/vhosts/award.m-2.ru/lib/db.conf.php";
include "/www/vhosts/award.m-2.ru/lib/mysql.class.php";
$db = new sql();
$db->connect();
$hc = new htmlcleaner();
$s = $hc->cleanup(stripslashes($s));
while (!feof($socket)) {
$buffer .= fread($socket, 1024);
}
$lines = explode("\n", $buffer);
foreach ($lines as $key => $value) {
if (trim($value)) {
$tmp = explode("|||", trim($value));
preg_match("'(\\d{1,2})\\.(\\d{1,2})\\.(\\d{1,4}) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})'", $tmp[1], $time_arr);
$tmp[1] = mktime($time_arr[4], $time_arr[5], $time_arr[6], $time_arr[2], $time_arr[1], $time_arr[3]);
$tmp[3] = str_replace("\\n", "||||||||n", $tmp[3]);
$tmp[3] = $hc->cleanup(stripslashes($tmp[3]));
$tmp[3] = str_replace("||||||||n", "\\n", $tmp[3]);
$res = $db->query("select id from news where matID={$tmp['0']}");
if (!$db->num_rows($res)) {
$db->query("insert into news set time='{$tmp['1']}', title='{$tmp['2']}', text='{$tmp['3']}', matID='{$tmp['0']}'");
}
$arr[] = $tmp;
}
}
print_r($arr);
示例10: appendEdit
function appendEdit()
{
$this->fields["time"] = mktime(0, 0, 0, $this->date["month"], $this->date["day"], $this->date["year"]);
foreach ($this->fields as $key => $value) {
$query .= "{$key}='{$value}', ";
}
$query .= "lmtime=" . @time();
$db = new sql();
$db->connect();
$db->query("update library set {$query} where id=" . $this->fields["id"]);
$db->query("delete from library_authors where library=" . $this->fields["id"]);
if (is_array($this->author)) {
foreach ($this->author as $key => $value) {
if ($value) {
$res = $db->query("select library from library_authors where library=" . $this->fields["id"] . " and author=" . $value);
if (!$db->num_rows($res)) {
$db->query("insert into library_authors set library=" . $this->fields["id"] . ", author=" . $value);
}
}
}
}
$page = "&page=" . $this->page;
header("Location: ?chid=" . $this->chid . "&m=3{$page}");
}
示例11: sql
function send_Messages()
{
include_once "lib/mail.class.php";
$conf = $this->conf();
$db = new sql();
$db->connect();
$res = $db->query("select * from subs_messages where id={$this->mid}");
$data = $db->fetch_array($res);
$page = $this->page ? $this->page : 1;
$res = $db->query("select * from subs_users left join subs_subscribed on subs_users.id=subs_subscribed.sid where lid={$this->id} limit " . 10 * ($page - 1) . ",10");
if ($db->num_rows($res)) {
while ($user = $db->fetch_array($res)) {
$i++;
$text["txt"] = $data["text"];
$text["html"] = $data["html"];
if ($data["text"]) {
$txt = $this->replaceMacros($conf["text"], $text, $conf, $user);
}
if ($data["html"]) {
$html = $this->replaceMacros($conf["html"], $text, $conf, $user);
}
$mail = new htmlMimeMail();
$mail->setSubject($data["subj"]);
$mail->setFrom($conf["email_from"]);
if ($html) {
$mail->setHtmlEncoding("base64");
$mail->setHTML($html, $txt, '');
} elseif ($txt && !$html) {
$mail->setText($txt);
}
$result = $mail->send(array($user["email"]));
}
$page++;
//echo "Location: ?chid=".$this->chid."&action=send_Messages&id=".$this->id."&mid=$this->mid&page=$page;";
header("Location: ?chid=" . $this->chid . "&action=send_Messages&id=" . $this->id . "&mid={$this->mid}&page={$page}&i={$i}");
} else {
if ($this->page) {
$count = 10 * ($this->page - 2) + $this->i;
$_SESSION["warning"] = "Писем отправлено: {$count}";
$db->query("update subs_messages set date_sent=" . time() . " where id={$this->mid}");
}
header("Location: ?chid=" . $this->chid . "&action=show_Messages&id=" . $this->id . "&w=1");
}
}
示例12: action_medialibrary
function action_medialibrary($args)
{
global $lang, $user;
$folder = isset($_REQUEST['folder']) ? $_REQUEST['folder'] : (isset($_SESSION['lastFolder']) ? $_SESSION['lastFolder'] : 1);
$_SESSION['lastFolder'] = $folder;
$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_ . "media_folder\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tID = '" . $folder . "'\r\n\t\t\t");
if (sql::num_rows($res) == 0) {
$res = sql::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_ . "media_folder\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t`order`\r\n\t\t\t\t\tLIMIT 1\r\n\t\t\t\t");
if ($row = sql::fetch_array($res)) {
$folder = $row['ID'];
}
}
$flash = false;
// Map Flash upload name to regular upload name
if (isset($_FILES['Filedata'])) {
$flash = true;
$_FILES['file'] =& $_FILES['Filedata'];
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['file'])) {
if ($_FILES['file']['error'] > UPLOAD_ERR_OK) {
error_log('Could not upload file because error ' . $_FILES['file']['error'] . ' occurred');
} else {
if (is_uploaded_file($_FILES['file']['tmp_name'])) {
$directory = _BASE_MEDIA_ . 'images/';
$original = $_FILES['file']['name'];
$contenttype = files::getCleanContentType($_FILES['file']['type'], $_FILES['file']['name']);
$filename = files::getUniqueName($contenttype, $directory);
if (files::allowedContentType($contenttype, 'picture')) {
// Move file to the media directory
move_uploaded_file($_FILES['file']['tmp_name'], $directory . $filename);
// Get information from the file...
list($width, $height) = getimagesize($directory . $filename);
$size = round(filesize($directory . $filename) / 1024);
// Insert it into the database
$res = sql::query("\r\n\t\t\t\t\t\t\t\tINSERT INTO\r\n\t\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t\tfolder = '" . $folder . "',\r\n\t\t\t\t\t\t\t\t\tfilename = '" . addslashes($filename) . "',\r\n\t\t\t\t\t\t\t\t\toriginal = '" . addslashes(basename($original)) . "',\r\n\t\t\t\t\t\t\t\t\twidth = '" . $width . "',\r\n\t\t\t\t\t\t\t\t\theight = '" . $height . "',\r\n\t\t\t\t\t\t\t\t\tsize = '" . $size . "',\r\n\t\t\t\t\t\t\t\t\tmodified = NOW()\r\n\t\t\t\t\t\t\t");
if ($flash) {
// Workaround for a Flash bug on OS X.. We need to send back content... any content will do
echo " ";
flush();
}
} else {
error_log('Could not upload file because its mimetype was not recognized or rejected');
}
} else {
error_log('Could not upload file because it got lost on the server');
}
}
if ($flash == false) {
header('Location: ' . url::action('medialibrary') . '?folder=' . $folder);
}
exit;
} else {
if (isset($_REQUEST['json'])) {
if ($_REQUEST['json'] == 'editImage' && isset($_REQUEST['image'])) {
$id = intval($_REQUEST['image']);
$res = sql::query("\r\n\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\toriginal = '" . addslashes($_REQUEST['value']) . "'\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tfolder = '" . $folder . "' AND\r\n\t\t\t\t\t\t\t\tid = '" . addslashes($id) . "'\r\n\t\t\t\t\t\t");
echo $_REQUEST['value'];
exit;
}
if ($_REQUEST['json'] == 'moveImage' && isset($_REQUEST['image'])) {
$ids = explode(',', $_REQUEST['image']);
while (list(, $id) = each($ids)) {
$res = sql::query("\r\n\t\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t\tfolder = '" . $folder . "'\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tid = '" . addslashes($id) . "'\r\n\t\t\t\t\t\t\t");
}
exit;
}
if ($_REQUEST['json'] == 'deleteImage' && isset($_REQUEST['image'])) {
$ids = explode(',', $_REQUEST['image']);
while (list(, $id) = each($ids)) {
$res = sql::query("\r\n\t\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t\tdeleted = 1\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tfolder = '" . $folder . "' AND\r\n\t\t\t\t\t\t\t\t\tid = '" . addslashes($id) . "'\r\n\t\t\t\t\t\t\t");
}
exit;
}
if ($_REQUEST['json'] == 'orderFolder' && isset($_REQUEST['folders'])) {
$order = 0;
while (list(, $id) = each($_REQUEST['folders'])) {
$res = sql::query("\r\n\t\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t\t`order` = " . $order . "\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tID = '" . addslashes($id) . "'\r\n\t\t\t\t\t\t\t");
$order++;
}
exit;
}
if ($_REQUEST['json'] == 'editFolder' && isset($_REQUEST['value'])) {
$res = sql::query("\r\n\t\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\tname = '" . addslashes($_REQUEST['value']) . "'\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tID = '" . addslashes($folder) . "'\r\n\t\t\t\t\t\t");
echo $_REQUEST['value'];
exit;
}
if ($_REQUEST['json'] == 'deleteFolder') {
$res = sql::query("\r\n\t\t\t\t\t\t\tDELETE FROM\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tID = '" . addslashes($folder) . "'\r\n\t\t\t\t\t\t");
exit;
}
if ($_REQUEST['json'] == 'newFolder') {
$res = sql::query("\r\n\t\t\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t\t\tMAX(`order`) AS max\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t");
if ($row = sql::fetch_array($res)) {
$order = $row['max'] + 1;
} else {
$order = 0;
}
$res = sql::query("\r\n\t\t\t\t\t\t\tINSERT INTO\r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "media_folder\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t`name` = '" . addslashes($user->lang->s('untitled')) . "',\r\n\t\t\t\t\t\t\t\t`order` = " . $order . "\r\n\t\t\t\t\t\t");
echo '[{id: "' . sql::insert_id() . '", name: "' . addslashes($user->lang->s('untitled')) . '"}]';
exit;
//.........这里部分代码省略.........
示例13: elseif
$mail->setHTML($html, $text, '');
} elseif ($data["text"] && !$data["html"]) {
$mail->setText($text);
}
$result = $mail->send(array($conf["test_email"]));
$i++;
header("Location: ?type=mod&mod_id=2&t=m&a=v&s={$i}");
}
} elseif ($t == 'u') {
$bn .= " — Подписчики";
$cn .= " — Подписчики";
if ($a == 'v') {
$db = new sql();
$db->connect();
$db->query("select * from subs_users order by id");
$nr = $db->num_rows($db->result);
$content = '<a href="?type=mod&mod_id=2&t=u&a=a">Добавить подписчика</a><br><br>
<table style="font-size: 80%;" cellpadding=5 cellspacing=1 width=50% bgcolor=silver>
<thead bgcolor="silver"><tr><td>E-mail</td><td>Действие</td></tr></thead>
<tbody bgcolor=white>';
while ($data = $db->fetch_array($db->result)) {
$i++;
$counter = !$counter;
$style = $counter ? " style=\"background-color: #F8F8F8;\"" : " style=\"background-color: #FFFFFF;\"";
$content .= "<tr><td width=100%>" . $data["email"] . "</td><td align=center><a href=\"?type=mod&mod_id=2&t=u&a=e&id=" . $data["id"] . "\" class=\"buttons\"><img src=\"img/edit.gif\" alt=\"Редактировать запись\" width=\"9\" height=\"9\" border=\"0\"></a> <a href=\"?type=mod&mod_id=2&t=u&a=d&id=" . $data["id"] . "\" class=\"buttons\"><img src=\"img/del.gif\" alt=\"Удалить запись\" width=\"9\" height=\"9\" border=\"0\" onClick=\"return submitdelete()\"></a></td></tr>";
}
$content .= "</tbody></table>";
}
if ($a == 'd') {
$db = new sql();
$db->connect();