当前位置: 首页>>代码示例>>PHP>>正文


PHP mysql_class::counts方法代码示例

本文整理汇总了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);
    }
}
开发者ID:snamper,项目名称:xiaoshuhaochi,代码行数:60,代码来源:function.load_data.php


注:本文中的mysql_class::counts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。