Phpcms How to get articles

Source: Internet
Author: User
Tags php database

Request Address Http://127.0.0.1/phpcms/index.php?m=content&c=index&a=show&catid=6&id=8

First to determine the address corresponding to the data table

Consult the PHPCMS V9 Datasheet structure Manual http://v9.help.phpcms.cn/html/2010/database_1228/107.html can tell that we're going to take out news,v9_news_data Two data in a table

The next step is to understand how the data is removed.

The associated controller is as follows

This is relatively simple to call the content module under the index controller's Show method data sheet structure manual

The next step describes how the show () method operates the database

Request Parameter Catid=6&id=6

And we already know that the article is stored in the Article Model table News,news_data table id=6 this line,

CATID for column ID query data sheet structure manual or open database can find _category column table can easily find

The article model for each column is defined by the ModelID field

Re-check the manual to confirm the modelid corresponding table model

So the request parameter is converted to a parameter in show () modelid=1&id=6

At this point we know to get =6 information in table News,news_data

Here's the operation database.

$tablename = $this->db->table_name = $this->db->db_tablepre. $MODEL [$modelid] [' tablename ']; $r = $this- >db->get_one (Array (' id ' = = $id), if (! $r | | $r [' status ']! =) ShowMessage (L (' info_does_not_exists '), ' blank ' ); $this->db->table_name = $tablename. ' _data '; $r 2 = $this->db->get_one (array (' id ' = = $id); $rs = $r 2? Array_merge ($r, $r 2): $r;

Remove Main Table contents and schedule contents

Where the Get_one method is implemented in the Mysql.class.php database class

$content _output = new Content_output ($modelid, $catid, $CATEGORYS);
$data = $content _output->get ($rs); If there is a cache, the read cache has no output $rs
Extract ($data); This is the function of PHP itself to use this function to import variables from the array into the current symbol table

<?php/* assumes that the $var _array is the array returned by the wddx_deserialize */$size = "large"; $var _array = Array ("Color" = "Blue",                   "size" 
   => "Medium",                   "shape" = "sphere") Extract ($var _array, Extr_prefix_same, "WDDX"), echo "$color, $size, $ Shape, $wddx _size\n ";? >
Blue, large, sphere, medium

It's easier to look at the template file again.

<Divclass= "Main">    <Divclass= "Col-left">        <Divclass= "Crumbs"><ahref= "{SiteURL ($siteid)}"><?php echo $title?>Home</a><span> &gt; </span>{Catpos ($catid)} body</Div>        <DivID= "article">            <H1>{$title}<BR/><span>{$inputtime}&nbsp;&nbsp;&nbsp;Source: {$copyfrom}&nbsp;&nbsp;&nbsp;Comments:<ahref= "#comment_iframe"ID= "comment">0</a>Click:</span><spanID= "hits"></span></H1>{if $description}<Divclass= "Summary" >{$description}</Div>{/if}<Divclass= "Content">{if $allow _visitor==1} {$content}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.