Phpcmsv9 label call, function, SQL _PHP tutorial

Source: Internet
Author: User
Phpcmsv9 label call, function, SQL. 1. the length of the call title {str_cut ($ r [title], 36,)} 2. formatting time call formatting Time 2011-05-0611: 22: 33 {date (Y-m-dH: I: s, $ r [inputtime])} 3. call multiple recommendations for multiple topics 1. extract the Call Title length

{Str_cut ($ r [title], 36 ,'')}

2. Format time

Call formatting time 11:22:33

{Date ('Y-m-d H: I: S', $ r [inputtime])}

3. multi-topic call & Multi-recommendation call

Call requirement: The article covers 59, 60, and 61 topics, and pushed two recommendation positions, 27 and 28;
Start from Article 3 and Call seven articles consecutively.

{Pc: get SQL = "SELECT * FROM v9_news WHERE id IN (SELECT id FROM v9_position_data WHERE posid in (27,28) and catid in (59,60, 61 )) order by listorder DESC "cache =" 3600 "start =" 3 "num =" 7 "return =" data "}
{Loop $ data $ n $ r}

  • ·

    1. call a single piece of data in the system. for example, if the call ID is 1, the title cannot exceed 25 Chinese characters and the updated date is displayed ):
    {Get SQL = "select * from phpcms_content where contentid = 1 "/}
    Title: {str_cut ($ r [title], 50)} URL: {$ r [url]} Update date: {date ('Y-m-D ', $ r [updatetime])}
    2. call multiple data entries in the system. for example, the call topic ID is 10 pieces of information that have passed the review. The title length cannot exceed 25 Chinese characters and the update date is displayed ):
    {Get SQL = "select * from phpcms_content where catid = 1 and status = 99 order by updatetime desc" rows = "10 "}
    Title: {str_cut ($ r [title], 50)} URL: {$ r [url]} Update date: {date ('Y-m-D ', $ r [updatetime])}
    {/Get}
    3. pagination. for example, (the ID of the calling topic is 10 pieces of information that have passed the review. the title cannot exceed 25 Chinese characters, and the updated date is displayed, with pagination ):
    {Get SQL = "select * from phpcms_content where catid = 1 and status = 99 order by updatetime desc" rows = "10" page = "$ page "}
    Title: {str_cut ($ r [title], 50)} URL: {$ r [url]} Update date: {date ('Y-m-D ', $ r [updatetime])}
    {/Get}
    Pagination: {$ pages}
    4. Custom return Variables. for example, the ID of the call topic is 10 pieces of information that have passed the review. The title length cannot exceed 25 Chinese characters, and the update date is displayed. the returned variable is $ v ):
    {Get SQL = "select * from phpcms_content where catid = 1 and status = 99 order by updatetime desc" rows = "10" return = "v "}
    Title: {str_cut ($ v [title], 50)} URL: {$ v [url]} Update date: {date ('Y-m-D ', $ v [updatetime])}
    {/Get}
    5. call other databases under the same account. for example, (the 10 latest topics with the called Database bbs and Classification ID 1 have no more than 25 Chinese characters and the update date is displayed ):
    {Get dbname = "bbs" SQL = "select * from cdb_threads where fid = 1 order by dateline desc" rows = "10 "}
    Theme: {str_cut ($ r [subject], 50)} URL: http://bbs.phpcms.cn/viewthread.php? Tid = {$ r [tid]} Update date: {date ('Y-m-D', $ r [dateline])}
    {/Get}
    6. call external data. for example, (the call data source is bbs, 10 latest topics with a category ID of 1, the topic length cannot exceed 25 Chinese characters, and the update date is displayed ):
    {Get dbsource = "bbs" SQL = "select * from cdb_threads where fid = 1 order by dateline desc" rows = "10 "}
    Theme: {str_cut ($ r [subject], 50)} URL: http://bbs.phpcms.cn/viewthread.php? Tid = {$ r [tid]} Update date: {date ('Y-m-D', $ r [dateline])}
    {/Get}

    Do you know if any of these methods cannot meet your needs?

    For example, if you want to retrieve a maximum of 3rd to 10th comments, some people say that I do this. Generally, there is no reason to choose the first and second comments, because the thumbnail of PHPCMS is better for the size of and the scaling effect on the long bar (such as) is not good, in order to manually update the first and second records with the most comments, therefore, you do not want to automatically update and read the first two items.



    • {$ R [comments]} comments {str_cut ($ r [title], 28 )}


    The key point is order by B. comments desc LIMIT 3, 7 (indicating reading 7 data records from 3rd Records) is often used in MYSQL. I tried it and the result is OK.

    The effect is as follows:

    I hope my PHPCMS developers can learn and share them together.

    Phpcms V9 retains the 2008 get tag usage

    It includes two methods: internal data and external data.

    First, let's analyze how to use internal data.

    1. call internal data

    {Pc: get SQL = "SELECT * FROM 'XX' WHERE fid = $ ltid AND digest = 2 AND ifupload = 1 ORDER BY tid DESC" num = "2" cache = "3600" return = ""data "}
    {Loop $ data $ r}

    .....

    {/Loop} {/pc}

    It can be seen that the get statement supports the use of num, but does not support the use of limit 5, 5.

    Sorry.

    Num is the number of calls.

    2. call external data

    {Pc: get SQL = "SELECT * FROM phpcms_member" cache = "3600" page = "$ page" dbsource = "discuz" return = "data "}

      {Loop $ data $ key $ val}

      {$ Val [username]} <br/>

      {/Loop}

      {$ Pages}

      {/Pc}

      One is the data source, and the other is the pages paging effect.

      This article from reprinted http://www.itokit.com/2012/0119/73007.html

      Else {str_cut ($ r [title], 36, '')} 2. formatting time call formatting time 11:22:33 {date ('Y-m-d H: I: S', $ r [inputtime])} 3. multi-topic call multi-recommendation adjustment...

  • 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.