The SQL tag in dedecms calls the data implementation method ({dede: SQL} tag)

Source: Internet
Author: User

Official Introduction to {dede: SQL}

Tag name: SQL function description: used to obtain the returned content from an SQL query in the template. Applicability: use the global basic syntax: {dede: SQL = ""} underlying Template {/dede: SQL} parameter description: SQL = "" complete SQL query statement underlying template field: all fields found in SQL statements can be called using [field: field name/].

Application instance:

1. Call the content of an article published by a specific member.

The code is as follows: Copy code

{Dede: SQL = 'select * from dede_archives where mid = 1 '}
<A href = '/plus/view. php? Aid = [field: id/] 'target = '_ blank'> [field: title/] </a>
{/Dede: SQL}

If mid is the user ID, see

Dede_archives data table fields in secondary development

Example

The code is as follows: Copy code

{Dede: SQL = 'SELECT d. typename, d. id, count (da. id) as heji from dede_arctype d left join dede_archives da on da. typeid = d. id where d. reid = 0 group by d. typename order by heji desc limit 0, 8 ;'}
<Li> [[field: heji/] [field: typename/] a total of articles delivered </li>
{/Dede: SQL}

An instance of my application calls a record

The code is as follows: Copy code

{Dede: SQL = 'select * from rschina_myad where aid = 24 '}
<Li class = "tab1"> <a href = "#1"> <span> [field: adname/] </span> </a> </li>
{/Dede: SQL}

{Dede: SQL = 'select * from rschina_myad where aid = 25 '}
<Li class = "tab2"> <a href = "#2"> <span> [field: adname/] </span> </a> </li>
{/Dede: SQL}

{Dede: SQL = 'select * from rschina_myad where aid = 26 '}
<Li class = "tab3"> <a href = "#3"> <span> [field: adname/] </span> </a> </li>
{/Dede: SQL}

{Dede: SQL = 'select * from rschina_myad where aid = 27 '}
<Li class = "tab4"> <a href = "#4"> <span> [field: adname/] </span> </a> </li>
{/Dede: SQL}

{Dede: SQL = 'select * from rschina_myad where aid = 28 '}
<Li class = "tab5"> <a href = "#5"> <span> [field: adname/] </span> </a> </li>
{/Dede: SQL}

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.