Home > CMS Tutorial > PHPCMS > Which table and field are the number of phpcms v9 article clicks?

Which table and field are the number of phpcms v9 article clicks?

angryTom
Release: 2019-11-09 11:26:26
Original
2183 people have browsed it

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(&#39;Y-m-d H:i:s&#39;,$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}
Copy after login

The third line is to get the number of clicks:

$db = pc_base::load_model(&#39;hits_model&#39;)
Copy after login

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 = &#39;&#39;;
      public function __construct() {
        $this->db_config = pc_base::load_config(&#39;database&#39;);
        $this->db_setting = &#39;default&#39;;
        $this->table_name = &#39;hits&#39;;
        parent::__construct();
    }
}
Copy after login

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 = &#39;&#39;, $data = &#39;*&#39;, $order = &#39;&#39;, $group = &#39;&#39;) {        
    if (is_array($where)) $where = $this->sqls($where);        
    return $this->db->get_one($data, $this->table_name, $where, $order, $group);
}
Copy after login

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

Which table and field are the number of phpcms v9 article clicks?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template