代码拉取完成,页面将自动刷新
在这个文件添加函数
application/cms/common.php
/**
* 获得文章总数
* @param $catid
* @param $where
*
* @return float|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
function articleCount($catid, $where)
{
$_item = db('category')->where(['id' => $catid])->find();
$_item = db('model')->where(['id' => $_item['modelid']])->find();
return db($_item['tablename'])->where($where)->count();
}
控制器 $condition = paramdecode(input('condition')); 输出到膜版
{php}
$sql='';
foreach($condition as $k => $v)
{
$sql .= ' and ' . $k . ' = "' . $v . '" ';
}
$sql = ' status = 1 ' . $sql . ' ';
{/php}
{:articleCount($catid,$sql)}
这样就能获得文章数量了。还兼顾了检索。
这块用的不多
取模型id可以用
$modelid = getCategory($catid, 'modelid');
取表名可以用
$model_cache = cache("Model");
$model_table = ucwords($model_cache[$modelid]['tablename']);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
谢谢。长知识了
登录 后才可以发表评论