phpcms v9文章点击数是哪个表哪个字段

来源:undefined 2025-01-06 10:36:56 1040

phpcms v9文章点击数是哪个表哪个字段

phpcms v9文章点击数在hits表views字段。

详解:

获取点击数的实例 

1

2

3

4

{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 $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array(commentid=>content_.$catid.-.$r[id].-.$modelid));}

登录后复制
{date(Y-m-d H:i:s,$r[inputtime])}·{$r[title]} 点击:{$views} 评论数:{if $comment_total}{$comment_total}{else}0{/if}{/loop} {$pages} {/pc}

其中的第3行是获取点击数:

立即学习PHP免费学习笔记(深入)”;

1

$db = pc_base::load_model(hits_model)

登录后复制

实例化对象为 $db,加载实例化类hit_model,该类的位置在 根目录phpcmsmodelhit_model.class.php文件中

1

2

3

4

5

6

7

8

9

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类中代码如下

1

2

3

4

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 表的结构如下

 注:hitsid 字段的数据 c-1-2 中 1表示当前模型id 2表示当前文章的id

以上就是phpcms v9文章点击数是哪个表哪个字段的详细内容,更多请关注php中文网其它相关文章!

最新文章