phpcms v9文章点击数是哪一个表哪一个字段
phpcms v9文章点击数正在hits表的views字段。
详解:
猎取点击数的实例
{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"} {loop $data $r} {php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; } {php $co妹妹ent_tag = pc_base::load_app_class("co妹妹ent_tag", "co妹妹ent"); $co妹妹ent_total = $co妹妹ent_tag->count(array('co妹妹entid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));} <li><span class="rt">{date('Y-m-d H:i:s',$r[inputtime])}</span>·<a href="{$r[url]}" target="_blank"{title_style($r[style])}>{$r[title]}</a> 点击:{$views} 评论数:{if $co妹妹ent_total}{$co妹妹ent_total}{else}0{/if}</li>{/loop} {$pages} {/pc}
此中的第3行是猎取点击数:
$db = pc_base::load_model('hits_model')
实例化工具为 $db,加载实例化类hit_model,该类的地位正在 根目次\phpcms\model\hit_model.class.php文件中
class hits_model extends model { public $table_name = ''; public function __construct() { $this->db_config = pc_base::load_config('database'); $this->db_setting = 'default'; $this->table_name = 'hits'; parent::__construct(); } }
该类文件加载承继了model类文件而且承继了其外部的办法,以是上面挪用get_one()办法
$_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])) 挪用$db工具中的get_one办法该办法位于hits_model承继的model类中代码以下
final public function get_one($where = '', $data = '*', $order = '', $group = '') { if (is_array($where)) $where = $this->sqls($where); return $this->db->get_one($data, $this->table_name, $where, $order, $group); }
get_one(arr('hitsid'=>'c-'.$modelid.'-'.$r[id]))办法中通报的数组为数据表v9_hits中的字段的值,其 hits 表的构造以下
此时的$_r为该表中的一条数据 数据表中的字段 views 即为该篇文章的点击次数 以是应用 $_r[views]便可猎取点击数啦!
注:hitsid 字段的数据 c-1-2 中 1示意以后模子id 2示意以后文章的id
以上就是phpcms v9文章点击数是哪一个表哪一个字段的具体内容,更多请存眷资源魔其它相干文章!
标签: phpcms phpcms教程 phpcms技巧 php问题解决 点击数
抱歉,评论功能暂时关闭!