本文整理汇总了PHP中Room::getRecordNum方法的典型用法代码示例。如果您正苦于以下问题:PHP Room::getRecordNum方法的具体用法?PHP Room::getRecordNum怎么用?PHP Room::getRecordNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room::getRecordNum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_rooms
function admin_rooms()
{
global $sr_default_chat_name;
// Show Rooms Page
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
if (!sr_is_signed_in()) {
sr_redirect('/d/main/signin/');
}
if (!sr_is_admin()) {
sr_redirect('/d/');
}
$db = sr_pdo();
$stmt = $db->prepare('SELECT * FROM room ORDER BY start_time DESC LIMIT 10');
$stmt->execute();
$room_list = $stmt->fetchAll(PDO::FETCH_CLASS, 'Room');
foreach ($room_list as $a_room) {
$room_id = $a_room->id;
$stmt = $db->prepare("SELECT name FROM participant WHERE room_id='{$room_id}'");
$stmt->execute();
$participants = $stmt->fetchAll(PDO::FETCH_COLUMN);
$a_room->participants = '';
foreach ($participants as $a_participant) {
if ($a_participant == '') {
$a_participant = $sr_default_chat_name;
}
$a_room->participants .= $a_participant . '<br />';
}
}
$stmt = $db->prepare('SELECT * FROM room_log ORDER BY id DESC LIMIT 10');
$stmt->execute();
$room_log_list = $stmt->fetchAll(PDO::FETCH_CLASS, 'RoomLog');
foreach ($room_log_list as $a_room_log) {
$room_id = $a_room_log->room_id;
$stmt = $db->prepare("SELECT participant_name FROM participant_log WHERE type=2 AND room_id='{$room_id}'");
$stmt->execute();
$participants = $stmt->fetchAll(PDO::FETCH_COLUMN);
$a_room_log->participants = '';
foreach ($participants as $a_participant) {
if ($a_participant == '') {
$a_participant = $sr_default_chat_name;
}
$a_room_log->participants .= $a_participant . '<br />';
}
}
$context = array('room_list' => $room_list, 'room_log_list' => $room_log_list);
sr_response('views/admin/rooms.php', $context);
// Handling Ajax Request
} else {
// Pagination or Filtering
if ($_POST['type'] == 'pagination') {
try {
$db = sr_pdo();
$json = $_POST['filter'];
$json = stripslashes($json);
$filter = json_decode($json);
$where = '';
$index = 0;
foreach ($filter as $field => $value) {
if ($index++ == 0) {
$where .= 'WHERE ';
} else {
$where .= ' AND ';
}
$where .= $field . '=' . $value;
}
if ($_POST['table'] == 't1') {
$total_record_number = Room::getRecordNum($filter);
} else {
$total_record_number = RoomLog::getRecordNum($filter);
}
if ($_POST['page_number'] == -1) {
$beginRecordNum = (int) ($total_record_number / 10) * 10;
} else {
$beginRecordNum = ($_POST['page_number'] - 1) * 10;
}
if ($_POST['table'] == 't1') {
$stmt = $db->prepare("SELECT * FROM room {$where} ORDER BY start_time DESC LIMIT {$beginRecordNum}, 10");
$stmt->execute();
$record_list = $stmt->fetchAll(PDO::FETCH_CLASS, 'Room');
foreach ($record_list as $a_room) {
$room_id = $a_room->id;
$stmt = $db->prepare("SELECT name FROM participant WHERE room_id='{$room_id}'");
$stmt->execute();
$participants = $stmt->fetchAll(PDO::FETCH_COLUMN);
$a_room->participants = '';
foreach ($participants as $a_participant) {
if ($a_participant == '') {
$a_participant = $sr_default_chat_name;
}
$a_room->participants .= $a_participant . '<br />';
}
}
} else {
$stmt = $db->prepare("SELECT * FROM room_log {$where} ORDER BY id DESC LIMIT {$beginRecordNum}, 10");
$stmt->execute();
$record_list = $stmt->fetchAll(PDO::FETCH_CLASS, 'RoomLog');
foreach ($record_list as $a_room_log) {
$room_id = $a_room_log->room_id;
$stmt = $db->prepare("SELECT participant_name FROM participant_log WHERE type=2 AND room_id='{$room_id}'");
$stmt->execute();
//.........这里部分代码省略.........
示例2: updateTable
$('#' + table + '_next, #' + table + '_end').attr('class', '');
}
if (last_page - first_page_in_view < 4) {
for (var btn = (last_page - 1) % 5 + 2; btn <= 5; btn++) {
$('#' + table + '_' + ordinal[btn]).attr('class', 'disabled');
}
}
}
// Initialize table
updateTable('t1', <?php
echo json_encode($context['room_list']);
?>
);
updateTable('t2', <?php
echo json_encode($context['room_log_list']);
?>
);
updatePage('t1', 1, <?php
echo Room::getRecordNum(array());
?>
);
updatePage('t2', 1, <?php
echo RoomLog::getRecordNum(array());
?>
);
</script>
</body>
</html>