Home >CMS Tutorial >PHPCMS >Which table and field are the number of phpcms v9 article clicks?
phpcms v9 article clicks are in which table and field
phpcms v9 article clicks are in hits The views field of table .
Detailed explanation:
Instance of getting the number of clicks
{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));} <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 $comment_total}{$comment_total}{else}0{/if}</li>{/loop} {$pages} {/pc}
The third line is to get the number of clicks:
$db = pc_base::load_model('hits_model')
Example The object is $db, and the instantiated class hit_model is loaded. The location of this class is in the root directory \phpcms\model\hit_model.class.php file
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(); } }
This class file is loaded and inherits the model class file and inherits Its internal method, so the get_one() method is called below
$_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r [id])) Call the get_one method in the $db object. This method is located in the model class inherited by hits_model. The code is as follows
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])) The array passed in the method is the value of the field in the data table v9_hits. The structure of the hits table is as follows
At this time $ _r is a field in the data table in the table views is the number of clicks on this article, so use $_r[views] to get the number of clicks!
Note: In the hitsid field data c-1-2, 1 represents the current model id and 2 represents the id of the current article
The above is the detailed content of Which table and field are the number of phpcms v9 article clicks?. For more information, please follow other related articles on the PHP Chinese website!