本文整理汇总了PHP中getblocksql函数的典型用法代码示例。如果您正苦于以下问题:PHP getblocksql函数的具体用法?PHP getblocksql怎么用?PHP getblocksql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getblocksql函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exit
/*
[SupeSite] (C) 2007-2009 Comsenz Inc.
模块语句生成:UCH日志
$Id: admin_blocks_uchblog_code.inc.php 11594 2009-03-11 05:44:43Z zhanglijun $
*/
if (!defined('IN_SUPESITE_ADMINCP')) {
exit('Access Denied');
}
$blockcodearr = array();
if ($_POST['blockmodel'] == '2') {
//高级模式
if (empty($_POST['sql'])) {
showmessage('block_thread_code_sql');
}
$_POST['sql'] = getblocksql($_POST['sql']);
$blockcodearr[] = 'sql/' . rawurlencode($_POST['sql']);
} else {
//向导模式
if ($_POST['setblogid']) {
//指定aid
$_POST['blogid'] = getdotstring($_POST['blogid'], 'int');
if (empty($_POST['blogid'])) {
showmessage('block_uchblog_code_blogid');
} else {
$blockcodearr[] = 'blogid/' . $_POST['blogid'];
}
} else {
if (!empty($_POST['picflag'])) {
$blockcodearr[] = 'picflag/' . $_POST['picflag'];
}
示例2: runsql
function runsql($paramarr, $bbsdb = '')
{
global $_SGLOBAL, $_SGET;
//处理SQL
$sqlstring = getblocksql($paramarr['sql']);
//初始化
$listcount = 1;
//连接数据库
$thedb = empty($bbsdb) ? $_SGLOBAL['db'] : $bbsdb;
//分页
if (!empty($paramarr['perpage'])) {
$countsql = '';
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)WHERE(.+?)ORDER', 2, 3);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)WHERE(.+?)LIMIT', 2, 3);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)WHERE(.+?)$', 2, 3);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)ORDER', 2, -1);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)LIMIT', 2, -1);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)$', 2, -1);
}
if (!empty($countsql)) {
$query = $thedb->query($countsql);
$listcount = $thedb->result($query, 0);
if ($listcount) {
$paramarr['perpage'] = intval($paramarr['perpage']);
if (empty($paramarr['perpage'])) {
$paramarr['perpage'] = 20;
}
if (empty($_SGET['page'])) {
$_SGET['page'] = 1;
}
$_SGET['page'] = intval($_SGET['page']);
if ($_SGET['page'] < 1) {
$_SGET['page'] = 1;
}
$start = ($_SGET['page'] - 1) * $paramarr['perpage'];
//SQL文
$sqlstring = preg_replace("/ LIMIT(.+?)\$/is", '', $sqlstring);
$sqlstring .= ' LIMIT ' . $start . ',' . $paramarr['perpage'];
}
}
} elseif (!empty($paramarr['limit'])) {
$paramarr['limit'] = getdotstring($paramarr['limit'], 'int', true, array(), 1, false);
if ($paramarr['limit']) {
//SQL文
$sqlstring = preg_replace("/ LIMIT(.+?)\$/is", '', $sqlstring);
$sqlstring .= ' LIMIT ' . $paramarr['limit'];
}
}
return array($sqlstring, $listcount);
}
示例3: runsql
function runsql($paramarr, $bbsdb = '', $returncount = 0, $multicachekey = '')
{
global $_G, $_SGLOBAL, $_SBLOCK;
//處理SQL
$sqlstring = getblocksql($paramarr['sql']);
//初始化
$listcount = 1;
//連接數據庫
//$thedb = empty($bbsdb)?$_SGLOBAL['db']:$bbsdb;
//分頁
if (!empty($paramarr['perpage'])) {
$countsql = '';
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)WHERE(.+?)ORDER', 2, 3);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)WHERE(.+?)LIMIT', 2, 3);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)WHERE(.+?)$', 2, 3);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)ORDER', 2, -1);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)LIMIT', 2, -1);
}
if (empty($countsql)) {
$countsql = getcountsql($sqlstring, 'SELECT(.+?)FROM(.+?)$', 2, -1);
}
if (!empty($countsql)) {
if ($returncount > 0) {
//需要更新計數緩存時
$listcount = DB::result_first($countsql);
return $listcount;
} else {
//無需更新緩存時
$listcount = intval(unserialize($_SBLOCK[$multicachekey]['value']));
}
if ($listcount) {
$paramarr['perpage'] = intval($paramarr['perpage']);
if (empty($paramarr['perpage'])) {
$paramarr['perpage'] = 20;
}
if (empty($_G['page'])) {
$_G['page'] = 1;
}
$_G['page'] = intval($_G['page']);
if ($_G['page'] < 1) {
$_G['page'] = 1;
}
$start = ($_G['page'] - 1) * $paramarr['perpage'];
//SQL文
$sqlstring = preg_replace("/ LIMIT(.+?)\$/is", '', $sqlstring);
$sqlstring .= ' LIMIT ' . $start . ',' . $paramarr['perpage'];
}
}
} elseif (!empty($paramarr['limit'])) {
$paramarr['limit'] = getdotstring($paramarr['limit'], 'int', true, array(), 1, false);
if ($paramarr['limit']) {
//SQL文
$sqlstring = preg_replace("/ LIMIT(.+?)\$/is", '', $sqlstring);
$sqlstring .= ' LIMIT ' . $paramarr['limit'];
}
}
return array($sqlstring, $listcount);
}
示例4: cachesql
public function cachesql($blockname, $sql, $cachetime = 0, $is_perpage = 0, $limit_or_perpage = 10, $limit_start = 0, $pagetype = 'other', $usetype = 'other', $shopid = 0, $infoid = 0)
{
if ($blockname && $sql) {
$blockcodearr = array();
$limit_or_perpage = intval($limit_or_perpage) > 0 ? intval($limit_or_perpage) : 10;
$limit_start = intval($limit_start);
$cachetime = intval($cachetime) > 0 ? intval($cachetime) : 0;
$sql = getblocksql($sql);
$blockcodearr[] = 'sql/' . rawurlencode($sql);
if ($is_perpage) {
$blockcodearr[] = 'perpage/' . $limit_or_perpage;
} else {
$blockcodearr[] = 'limit/' . $limit_start . ',' . $limit_or_perpage;
}
$cachetime && ($blockcodearr[] = 'cachetime/' . $cachetime);
$blockcodearr[] = 'cachename/' . rawurlencode($blockname);
$blockcodearr[] = 'pagetype/' . rawurlencode($pagetype);
$blockcodearr[] = 'usetype/' . rawurlencode($usetype);
$blockcodearr[] = 'shopid/' . intval($shopid);
$blockcodearr[] = 'infoid/' . intval($infoid);
$returnst = block('sql', implode('/', $blockcodearr));
if ($this->allowcache) {
return $returnst;
} else {
return false;
}
} else {
return false;
}
}