Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by JetBrains PhpStorm.
- * User: pavel
- * Date: 22.09.11
- * Time: 14:52
- * To change this template use File | Settings | File Templates.
- * Many changes by SLIM (skype: anton_slim)
- */
- require_once('classes/pdo_mysql.php');
- class magazin extends mysql
- {
- function print_magazin()
- {
- $res = $this->query("SELECT * FROM magazin ORDER BY id DESC");
- echo '<table class="table_border" style="width: 800px;"><tr>
- <th style="width:150px;">Дата</th><th>Кто</th><th>Действие</th><th style="width:50%">Подробно</th>
- </tr>';
- if ($res) {
- foreach($res as $val){
- echo '<tr><td>'.$val['data'].'</td><td>'.$val['author'].'</td><td><b>'.$val['filter'].'</b></td><td>'.$val['doing'].'</td></tr>';
- }
- }
- echo '</table>';
- }
- public function getData($filter, $page, $onPage = 20)
- {
- $q = "SELECT *, DATE_FORMAT(`date`, '%e %M, %Y') as date_str, DATE_FORMAT(`date`, '%H:%i') as hour_str FROM `magazin` %where% ORDER BY `id` DESC %limitPage%";
- $q = $this->_limitPage($q, $page, $onPage);
- $where = $this->_where($filter);
- $res = $this->query($q, $where);
- return $res;
- }
- protected function _limitPage($sql, $page, $rowCount)
- {
- $page = ($page > 0) ? $page : 1;
- $rowCount = ($rowCount > 0) ? $rowCount : 1;
- $sql = str_replace('%limitPage%', 'LIMIT '.( $rowCount * ($page - 1) ).', '. (int)$rowCount, $sql);
- return $sql;
- }
- function get_unique_users()
- {
- $res = $this->fetchPairs("SELECT `id_user`, `author` FROM `magazin` GROUP BY `author` ORDER BY `author`");
- return $res;
- }
- function get_unique_actions()
- {
- $res = $this->fetchPairs("SELECT `action` FROM `magazin` GROUP BY `action` ORDER BY `action`");
- return $res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement