本文整理匯總了PHP中mysql_class::counts方法的典型用法代碼示例。如果您正苦於以下問題:PHP mysql_class::counts方法的具體用法?PHP mysql_class::counts怎麽用?PHP mysql_class::counts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mysql_class
的用法示例。
在下文中一共展示了mysql_class::counts方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: smarty_function_load_data
function smarty_function_load_data($params, &$smarty)
{
(!isset($params['table']) || empty($params['table'])) && exit('`table` is empty!');
// $Mconfig = include(hopedir."config/hopeconfig.php");
// print_r($Mconfig);
$type = isset($params['type']) ? $params['type'] : 'list';
//total 總數量 one list 3個分類
$fileds = isset($params['fileds']) ? $params['fileds'] : '*';
$where = isset($params['where']) ? $params['where'] : '';
$where = empty($where) ? '' : ' where ' . $where;
$orderby = isset($params['orderby']) ? 'order by ' . $params['orderby'] : '';
$limit = isset($params['limit']) ? 'LIMIT 0,' . $params['limit'] : 'LIMIT 0,1';
if (!class_exists('mysql_class')) {
include hopedir . "lib/core/extend/mysql_class.php";
//core\extend
$mysql = new mysql_class();
} else {
$mysql = new mysql_class();
}
$page = intval(IFilter::act(IReq::get('page')));
$pagesize = intval(IFilter::act(IReq::get('pagesize')));
$pagesize = isset($params['pagesize']) ? $params['pagesize'] : $pagesize;
$pagesize = empty($pagesize) ? 10 : $pagesize;
// $db = $class::factory(array('table' => $params['table']));
//var_dump($params);
if (!empty($params['assign'])) {
//把數據賦值給變量$params['assign'],這樣前端就可以使用這個變量了(例如可以結合foreach輸出一個列表等)
// $smarty->assign($params['assign'], $db->get_block_list(array($params['where']), $params['limit']));
if ($type == 'total') {
$result = $mysql->counts("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " " . $orderby . " " . $limit . "");
} elseif ($type == 'one') {
$result = $mysql->select_one("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " " . $orderby . " " . $limit . "");
} else {
if (isset($params['showpage']) && $params['showpage'] == true) {
if (!class_exists('page')) {
include hopedir . "lib/core/extend/page.php";
//core\extend
$pageclass = new page();
} else {
$pageclass = new page();
}
$pageclass->setpage($page, $pagesize);
$result['list'] = $mysql->getarr("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " " . $orderby . " limit " . $pageclass->startnum() . ", " . $pageclass->getsize() . "");
$shuliang = $mysql->counts("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " ");
$pageclass->setnum($shuliang);
if (isset($params['pagetype'])) {
$result['pagecontent'] = $pageclass->ajaxbar($params['pagetype']);
} else {
$result['pagecontent'] = $pageclass->getpagebar();
}
} else {
$result['list'] = $mysql->getarr("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " " . $orderby . " " . $limit . "");
}
}
/*
$result['list'] = array();
$result['pagecontent'] = ''; */
$smarty->assign($params['assign'], $result);
}
}