本文整理匯總了PHP中db::limit方法的典型用法代碼示例。如果您正苦於以下問題:PHP db::limit方法的具體用法?PHP db::limit怎麽用?PHP db::limit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類db
的用法示例。
在下文中一共展示了db::limit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: view
function view()
{
db::table('admin_log_actions');
db::join('admin_users', 'admin_log_actions', 'user_id');
db::order('log_date', 'DESC');
db::limit(30);
$res = db::select();
while ($row = mysql_fetch_assoc($res)) {
$row['log_date'] = dt::format('%d.%m.%Y %H:%M', $row['log_date']);
s::roll('logs_list', $row);
}
}
示例2: start
function start()
{
db::connect();
if (!router::get(1)) {
return true;
}
self::$map = array('mode' => router::get(0), 'app' => router::get(1), 'module' => 'main', 'action' => router::get(2), 'id' => router::get(4));
s::set('SYS_PATH', 'http://' . SERVER . SYS_DIR);
define('APP', APPS . self::get('app') . '/');
s::set('APP', APP);
define('MODULE', APP . self::get('module') . '/');
s::set('MODULE', MODULE);
if (stristr(self::$map['mode'], 'admin')) {
self::$map['mode'] = 'admin';
} else {
self::$map['mode'] = 'web';
}
if (self::$map['mode'] == 'admin') {
if (defined('ADMIN_USER_SITE_ID')) {
admin::observer();
define('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
s::set('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
db::table('admin_sites');
db::where('site_id', ADMIN_USER_SITE_ID);
db::limit(1);
$row = db::select();
define('ADMIN_SITE', db::get('site_domain'));
s::set('ADMIN_SITE', ADMIN_SITE);
}
} else {
web::getSite();
$lang = lang::gets(LANG_INDEX, SITE_ID);
/*
Authentification webUser
*/
web::observer();
}
/*
Set params
*/
params::send();
if (router::get(0) == 'feed' || router::get(0) == 'rss') {
self::$map['module'] = 'feed';
}
if (self::$map['mode'] == 'admin') {
load::module(self::get('app'), self::get('module'), self::get('action'));
} else {
load::handler(self::get('app'), self::get('module'), self::get('action'));
}
}
示例3: show
function show()
{
$list = params::get('list');
$event = web::getEvent();
if ($event === false) {
$year = date('Y');
} else {
$year = $event;
}
s::set('news_date_select', htmlspecialchars($year));
$sql = "SELECT DATE_FORMAT(`news_date`, '%Y') as date FROM `news` GROUP BY `date` ORDER BY `date` DESC";
$res = db::query($sql);
$rows = mysql_num_rows($res);
if ($rows > 1) {
s::add('news_date_selector', '<ul class="years">');
while ($row = mysql_fetch_assoc($res)) {
if ($row['date'] == $year) {
$row['date'] = '<li><span>' . $row['date'] . '</span></li>';
} else {
$row['date'] = '<li><a href="' . web::get('page_folder') . '' . $row['date'] . '/">' . $row['date'] . '</a></li>';
}
s::add('news_date_selector', $row['date']);
}
s::add('news_date_selector', '</ul>');
}
db::table('news');
db::where('news_pub', '1');
db::where('news_date', $year . '-01-01 00:00:00', '>=');
db::where('news_date', $year . '-12-31 23:59:59', '<=');
db::order('news_date', 'DESC');
if ($list !== false) {
db::limit($list);
}
$res = db::select();
if (db::rows() == 0) {
web::error404();
}
while ($row = mysql_fetch_assoc($res)) {
$row['news_date'] = dt::date2print('%d %F %Y', $row['news_date']);
s::roll('news', $row);
}
}
示例4: load
function load($user_id)
{
if (self::$user) {
return true;
}
db::table('admin_users');
db::where('user_id', $user_id);
db::where('user_pub', 1);
db::limit(1);
self::$user = db::assoc();
if (db::rows() == 0) {
admin::logout();
}
define("ADMIN_USER_ID", $user_id);
define("ADMIN_USER_SITE_ID", self::get('site_id'));
define("ADMIN_USER_GROUP_ID", self::get('group_id'));
s::set('ADMIN_USER_LOGIN', self::get('user_login'));
s::set('ADMIN_USER_ID', $user_id);
return true;
}
示例5: loadPage
function loadPage($page_id = false, $page_folder = false)
{
db::table('pages');
db::join('templates', 'pages', 'tmpl_id');
if ($page_id) {
db::where('page_id', $page_id);
}
if ($page_folder) {
db::where('page_folder', $page_folder);
}
db::where('site_id', SITE_ID, '=', 'pages');
db::limit(1);
$res = db::select();
if (db::rows() == 1) {
$row = mysql_fetch_assoc($res);
$row = web::pageSettings($row);
web::$page = $row;
s::set($row);
}
}
示例6: dump
function dump()
{
$tables = implode(', ', self::$tables);
$conf = implode(', ', self::$conf);
db::table('admin_log_trash');
db::order('log_id', 'DESC');
db::limit(31, 100);
$res = db::select('log_id');
if (db::rows() > 0) {
while ($row = mysql_fetch_assoc($res)) {
self::delete($row['log_id']);
}
}
if (self::$files) {
$log_tmpl = 1;
} else {
$log_tmpl = 0;
}
db::table('admin_log_trash');
db::insert('', 'NOW()', '', $tables, $conf, '', $log_tmpl, ADMIN_USER_ID);
$log_id = mysql_insert_id();
dump::tables(self::$tables);
dump::backup(SYS_ROOT . 'var/trash/' . $log_id . '_base.zip');
if (self::$conf) {
foreach (self::$conf as $v) {
zipfile::add(SYS_ROOT . 'conf/web/' . $v . '.ini');
}
zipfile::create(SYS_ROOT . 'var/trash/' . $log_id . '_conf.zip');
}
if (self::$files) {
foreach (self::$files as $v) {
zipfile::add($v);
}
zipfile::create(SYS_ROOT . 'var/trash/' . $log_id . '_files.zip');
}
}
示例7: view
function view()
{
db::table('admin_log_trash');
db::limit(30);
db::order('log_date', 'DESC');
$res = db::select();
while ($row = mysql_fetch_assoc($res)) {
if ($row['log_restored'] != '0000-00-00 00:00:00') {
$row['log_restored'] = dt::date2print('%H:%i:%s<br />%d %F %y', $row['log_restored']);
} else {
$row['log_restored'] = '';
}
$row['log_date'] = dt::date2print('%H:%i:%s<br />%d %F %y', $row['log_date']);
$tables = '';
$array = explode(",", $row['log_tables']);
foreach ($array as $v) {
if (!empty($v)) {
$tables .= T_ . $v . '<br />';
}
}
$row['log_tables'] = $tables;
s::roll('basket', $row);
}
}
示例8: saveVersion
function saveVersion($app, $tmpl_file, $code)
{
db::table('templates_versions');
db::where('app', $app);
db::where('tmpl_file', $tmpl_file);
db::where('version_code', $code);
db::order('version_date', 'DESC');
db::limit(1);
db::select();
if (db::rows() == 0) {
/*
delete over 10
*/
db::table('templates_versions');
db::where('app', $app);
db::where('tmpl_file', $tmpl_file);
db::order('version_date', 'DESC');
db::limit(10, 100);
db::delete();
db::table('templates_versions');
db::insert('', 'NOW()', $code, $app, $tmpl_file, 0, ADMIN_SITE_ID);
}
}
示例9: start
//.........這裏部分代碼省略.........
define('MODULE', APP . self::$map['module'] . '/');
s::set('MODULE', MODULE);
/*
Get sites list
*/
db::table('admin_sites');
$res = db::select();
if (db::rows() > 1) {
$str = '<div class="popup popupSimple" id="site_list_load_popup" style="display: none;"><ul>';
while ($row = mysql_fetch_assoc($res)) {
if (self::$sites_excl) {
if (!isset(self::$sites_excl[$row['site_id']])) {
continue;
}
}
if ($row['site_id'] == ADMIN_USER_SITE_ID) {
define('ADMIN_SITE', $row['site_domain']);
s::set('ADMIN_SITE', ADMIN_SITE);
s::set('admin_site_selector', ' <a href="javascript:void(null);" class="ico ico11 ico_popup popupLoad" id="site_list_load"> </a>');
} else {
$str .= '<li><a class="popup_right" title="Перейти на сайт" href="http://' . $row['site_domain'] . '"></a><a href="javascript:void(null);" title="Выбрать сайт" onclick="sysSetSite(' . $row['site_id'] . ');">' . $row['site_domain'] . '</a></li>';
}
}
$str .= '</ul></div>';
s::set('admin_site_list', $str);
} else {
$row = mysql_fetch_assoc($res);
define('ADMIN_SITE', $row['site_domain']);
s::set('ADMIN_SITE', ADMIN_SITE);
}
define('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
s::set('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
/*
Action tmpls
*/
if (self::$map['rule'] == 'all') {
$rule_folder = 'all/';
} else {
$rule_folder = RULE . '/';
}
// context_menu
$context_tmpl = MODULE . $rule_folder . self::$map['action'] . '.context.html';
s::set('admin_context_menu', files::get($context_tmpl));
// area
$area_tmpl = MODULE . $rule_folder . self::$map['action'] . '.html';
s::set('admin_area', files::get($area_tmpl));
// sidebar
$sidebar_tmpl = MODULE . $rule_folder . self::$map['action'] . '.bar.html';
s::set('admin_sidebar', files::get($sidebar_tmpl));
/*
App CSS and JS
*/
$app_css = 'apps/' . self::$map['app'] . '/' . self::$map['app'] . '.css';
$app_js = 'apps/' . self::$map['app'] . '/' . self::$map['app'] . '.js';
if (file_exists(SYS_ROOT . $app_css)) {
self::insertCSS('http://' . SERVER . SYS_DIR . $app_css);
}
if (file_exists(SYS_ROOT . $app_js)) {
self::insertJS('http://' . SERVER . SYS_DIR . $app_js);
}
/*
Module CSS and JS
*/
$module_css = 'apps/' . self::$map['app'] . '/' . self::$map['module'] . '/' . self::$map['module'] . '.css';
$module_js = 'apps/' . self::$map['app'] . '/' . self::$map['module'] . '/' . self::$map['module'] . '.js';
if (file_exists(SYS_ROOT . $module_css)) {
self::insertCSS('http://' . SERVER . SYS_DIR . $module_css);
}
if (file_exists(SYS_ROOT . $module_js)) {
self::insertJS('http://' . SERVER . SYS_DIR . $module_js);
}
/*
Legenda app, module and action
*/
load::appSetup(self::$map['app']);
load::moduleSetup(self::$map['app'], self::$map['module']);
load::module(self::$map['app'], self::$map['module'], self::$map['action']);
/*
User log
*/
adminUser::update('user_date_last', 'NOW()', ADMIN_USER_ID);
/*
Action log
*/
db::table('admin_log_actions');
db::where('log_path', URI_SELF);
db::where('user_id', ADMIN_USER_ID);
db::order('log_date', 'DESC');
db::limit(1);
db::select('log_id');
if (db::rows() == 0) {
db::table('admin_log_actions');
db::insert('', 'NOW()', self::get('app'), self::get('module'), self::get('action'), URI_SELF, self::get('title'), ADMIN_USER_ID);
}
/*
Legenda display
*/
self::adminMenu();
self::display($sys_tmpl, $lang);
}
示例10: saveVersion
function saveVersion($tmpl_id, $code)
{
db::table('templates_versions');
db::where('tmpl_id', $tmpl_id);
db::where('version_code', $code);
db::order('version_date', 'DESC');
db::limit(1);
db::select();
if (db::rows() == 0) {
/*
delete over 20
*/
db::table('templates_versions');
db::where('tmpl_id', $tmpl_id);
db::order('version_date', 'DESC');
db::limit(20, 100);
db::delete();
db::table('templates_versions');
db::insert('', 'NOW()', $code, '', '', $tmpl_id, ADMIN_USER_ID, ADMIN_SITE_ID);
}
}
示例11: get
function get($name)
{
if (!self::$user) {
db::table('users');
db::where('user_id', $_SESSION['WEB_USER_ID']);
db::where('user_pub', 1);
db::limit(1);
self::$user = db::assoc();
}
if (!isset(self::$user[$name])) {
return false;
}
return self::$user[$name];
}
示例12: start
function start()
{
db::connect();
if (!router::get(1)) {
return true;
}
self::$map = array('mode' => router::get(0), 'app' => router::get(1), 'module' => 'main', 'action' => router::get(2));
if (router::get(3)) {
self::set('module', router::get(2));
self::set('action', router::get(3));
}
s::set('SYS_PATH', 'http://' . SERVER . SYS_DIR);
define('APP', APPS . self::get('app') . '/');
s::set('APP', APP);
define('MODULE', APP . self::get('module') . '/');
s::set('MODULE', MODULE);
/*
Lang items
*/
if (self::get('mode') == 'webAjax') {
web::getSite();
$lang = lang::gets(LANG_INDEX, SITE_ID);
/*
Authentification webUser
*/
web::observer();
} else {
define('LANG_INDEX', SYS_INDEX);
$lang = lang::gets(LANG_INDEX);
admin::observer();
if (defined('ADMIN_USER_SITE_ID')) {
define('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
s::set('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
$group_rules = ini::parse(SYS_ROOT . 'conf/admin/groups.ini', ADMIN_USER_GROUP_ID);
define('RULE', $group_rules['rule']);
db::table('admin_sites');
db::where('site_id', ADMIN_USER_SITE_ID);
db::limit(1);
define('ADMIN_SITE', db::get('site_domain'));
s::set('ADMIN_SITE', ADMIN_SITE);
}
}
/*
Set params
*/
params::send();
$tmpl = params::get('tmpl');
$sys = false;
if (self::get('mode') == 'adminAjax') {
$sys = true;
}
buffer::init(0, self::get('app'), false, $tmpl);
if (self::get('mode') == 'webAjax') {
load::handler(self::get('app'), self::get('module'), self::get('action'));
} else {
load::module(self::get('app'), self::get('module'), self::get('action'));
}
/*
Get plugin action
*/
ob_start();
/*
запуск обработчика с возвратом данных
тут два варианта либо данные просто выводим если нет шаблона, а если есть то сначала обрабатываем шаблон
если буффер полный выводим информацию из него
*/
$buffer = buffer::gets();
if ($buffer[0]) {
if ($sys) {
buffer::$module = self::get('module');
}
$section = params::get('section');
echo buffer::get($buffer[0]['app'], $buffer[0]['tmpl'], $buffer[0]['data'], $section, $sys);
}
$code = ob_get_contents();
ob_clean();
s::$mode = 'code';
s::setTmpl($code, $lang);
s::display();
}
示例13: delete
function delete($page_id = false, $dump = true)
{
if (!$page_id) {
$page_id = params::get('page_id');
}
if ($page_id == 1) {
return false;
}
db::table('pages');
db::where('page_id', $page_id);
db::limit(1);
$page = db::assoc();
if ($page['page_child'] == '1') {
return false;
}
if ($dump) {
trash::tables('pages', 'pages_content', 'pages_versions');
trash::conf('pages', 'blocks', 'menus');
trash::dump();
}
$parent = $page['page_parent'];
if ($parent != 0) {
db::table('pages');
db::where('page_parent', $parent);
db::select();
if (db::rows() == 1) {
db::table('pages');
db::where('page_id', $parent);
db::update('page_child', '0');
}
}
db::table('menus_points');
db::where('site_id', $page['site_id']);
db::where('point_link', $page['page_folder']);
db::delete();
db::table('pages');
db::where('page_id', $page_id);
db::delete();
db::table('pages_content');
db::where('page_id', $page_id);
db::delete();
db::table('pages_versions');
db::where('page_id', $page_id);
db::delete();
conf::delete('pages', $page_id);
conf::deleteFrom('blocks', 'pages', $page_id);
conf::deleteFrom('menus', 'pages', $page_id);
db::table('pages_files');
db::where('page_id', $page_id);
$r = db::select();
while ($a = mysql_fetch_assoc($r)) {
self::deleteFilesFileForce($a);
}
}
示例14: getSite
function getSite()
{
db::table('admin_sites');
db::where('site_domain', parent::$site);
db::where('site_pub', 1);
db::limit(1);
$site = db::assoc();
if ($site) {
define('SITE_ID', $site['site_id']);
define('SITE_DOMAIN', $site['site_domain']);
define('LANG_INDEX', $site['lang_index']);
} else {
define('SITE_ID', 0);
define('SITE_DOMAIN', false);
define('LANG_INDEX', 'ru');
}
}
示例15: pager
function pager($per_page)
{
self::$pager_per_page = $per_page;
self::$pager_uri = '';
if (isset($_GET['page'])) {
self::$cur_page = $_GET['page'];
}
self::$pager_uri = strtok($_SERVER['REQUEST_URI'], "?") . "?";
if (count($_GET)) {
foreach ($_GET as $k => $v) {
if (!is_array($v)) {
if ($k != "page") {
self::$pager_uri .= urlencode($k) . "=" . urlencode($v) . "&";
}
}
}
}
$start = abs((self::$cur_page - 1) * self::$pager_per_page);
db::limit($start, self::$pager_per_page);
self::$start = $start;
self::$pager = true;
}