本文整理汇总了PHP中SQL::num方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::num方法的具体用法?PHP SQL::num怎么用?PHP SQL::num使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::num方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stripslashes
if (strlen($forum_user['realname']) > 0) {
echo stripslashes(rtrim($forum_user['realname']));
} else {
echo stripslashes(rtrim($forum_user['username']));
}
echo '</strong></a>';
echo '<br/><span style="font-size:11px;">Last Visit: ' . date('d/m/Y g:i A', $forum_user['last_visit']) . '</span>';
echo '<br/><a href="../forum/profile.php?section=identity&id=' . $forum_user['id'] . '" style="font-size:11px;">Edit Profile</a>';
echo '</div>';
echo '</div>';
$db = new SQL(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, false);
$user_id = $forum_user['id'];
$query1 = $db->query("SELECT id FROM ip_shouts WHERE user_id='{$user_id}'");
$query2 = $db->query("SELECT id FROM ip_updates WHERE user_id='{$user_id}'");
$query3 = $db->query("SELECT id FROM ip_requests WHERE user_id='{$user_id}'");
$total1 = $db->num($query1);
$total2 = $db->num($query2);
$total3 = $db->num($query3);
echo '<div class="user-topleft-nav">';
echo '<ul class="nav nav-list">';
echo '<li><a href="profile.php?id=' . $forum_user['id'] . '&sp=shouts" style="color:#333"><i class="icon-comments-alt muted"></i> My Messages <span class="badge pull-right" style="margin-top:1px;">' . $total1 . '</span></a></li>';
echo '<li><a href="profile.php?id=' . $forum_user['id'] . '&sp=updates" style="color:#333"><i class="icon-list-alt muted"></i> My Updates <span class="badge pull-right" style="margin-top:1px;">' . $total2 . '</span></a></li>';
echo '<li><a href="profile.php?id=' . $forum_user['id'] . '&sp=requests" style="color:#333"><i class="icon-list-alt muted"></i> My Requests <span class="badge pull-right" style="margin-top:1px;">' . $total3 . '</span></a></li>';
echo '</ul>';
?>
</div>
</div>
<div class="left-menu">
<ul class="nav nav-list">
<li class="nav-header">Forum Quick Links</li>
示例2: SQL
<?php
html_footer();
?>
<div id="ipStats" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">IsharePortal Statistics</h3>
</div>
<div class="modal-body">
<div class="stat-data">
<?php
require_once SITE_ROOT . 'portal_config.php';
require_once SITE_ROOT . 'include/database.class.php';
$db = new SQL(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, false);
$t_users = $db->num($db->query("SELECT id FROM forum_users")) - 1;
$t_shouts = $db->num($db->query("SELECT id FROM ip_shouts"));
$t_updates = $db->num($db->query("SELECT id FROM ip_updates"));
$t_requests = $db->num($db->query("SELECT id FROM ip_requests"));
$t_reply = $db->num($db->query("SELECT id FROM ip_reply"));
$t_sharerlinks = $db->num($db->query("SELECT id FROM ip_sharerlinks"));
echo 'Total of registered users: <strong>' . $t_users . ' usernames</strong><br/>';
echo 'Total of current shouts: <strong>' . $t_shouts . ' messages</strong><br/>';
echo 'Total of <code>!update</code> shouts: <strong>' . $t_updates . ' messages</strong><br/>';
echo 'Total of <code>!request</code> shouts: <strong>' . $t_requests . ' messages</strong><br/>';
echo 'Total of replies: <strong>' . $t_reply . ' messages</strong><br/>';
echo 'Total of sharerlinks: <strong>' . $t_sharerlinks . ' links</strong><br/>';
$top5 = $db->query("SELECT user_id, COUNT(user_id) AS top5 FROM ip_shouts GROUP BY user_id ORDER BY top5 DESC LIMIT 5");
$rank = 1;
echo 'Top 5 Shouters:<br/>';
while ($row = $db->fetch_assoc($top5)) {
示例3: define
<?php
if (!defined('SITE_ROOT')) {
define('SITE_ROOT', '../');
}
require_once SITE_ROOT . 'portal_config.php';
require_once SITE_ROOT . 'include/database.class.php';
$db = new SQL(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, false);
$query = $db->query("SELECT id FROM forum_users");
$total_users = $db->num($query) - 1;
echo $total_users;
$db->close();
示例4: define
<?php
if (!defined('SITE_ROOT')) {
define('SITE_ROOT', '../');
}
require_once SITE_ROOT . 'portal_config.php';
require_once SITE_ROOT . 'include/database.class.php';
$db = new SQL(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, false);
$query = $db->query("SELECT user_id FROM forum_online");
echo $db->num($query);
$db->close();
示例5: implode
<?php
if (!defined('SITE_ROOT')) {
define('SITE_ROOT', '../');
}
require_once SITE_ROOT . 'portal_config.php';
require_once SITE_ROOT . 'include/database.class.php';
// Removing messages older than X days
$keep_period1 = time() - 86400 * KEEP_SHOUTS;
$keep_period2 = time() - 86400 * KEEP_REQUESTS;
$keep_period3 = time() - 86400 * KEEP_UPDATES;
$keepdb = new SQL(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, false);
$keepq1 = $keepdb->query("SELECT id FROM ip_shouts WHERE shout_time < {$keep_period1}");
if ($keepdb->num($keepq1) > 0) {
$keepdb->query("DELETE FROM ip_shouts WHERE shout_time < {$keep_period1}");
}
$keepq2 = $keepdb->query("SELECT id FROM ip_requests WHERE shout_time < {$keep_period2}");
if ($keepdb->num($keepq2) > 0) {
$keepdb->query("DELETE FROM ip_requests WHERE shout_time < {$keep_period2}");
}
$keepq3 = $keepdb->query("SELECT id FROM ip_updates WHERE shout_time < {$keep_period3}");
if ($keepdb->num($keepq3) > 0) {
$keepdb->query("DELETE FROM ip_updates WHERE shout_time < {$keep_period3}");
}
$keepdb->close();
// End of Removing messages older than X days
$db = new SQL(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, false);
$db->query("SELECT COUNT(id) FROM ip_shouts");
echo implode($db->fetch_assoc());
$db->close();