Kill lui lei Dog---dedecms----18dedecms of the helpless label-sql tag Remove today update

Source: Internet
Author: User

We can try out the SQL tags we dedecms when we encounter some problems when we have no common label to solve in the development time, almost can complete any query request

The syntax is as follows:

We will be here just now the homepage of the update that piece to rewrite, the original is:

{dede:arclist flag= "H" row= "5" channelid= "" Addfields= "Yuyan,pingfen"}<Liclass= "c[field:global.autoindex/]">                                       <ahref= "http://www.a67.com/movie/7989"Target= "_blank">                                           <imgsrc= "[field:litpic/]"alt= "[field:title/] 3GP MP4 HD Download" />                                       </a>                                       <P>[field:yuyan/]</P>                                       <b>                                           <ahref= "http://www.a67.com/movie/7989"Target= "_blank">[field:title/]</a>                                           <imgsrc= "[Field:global.cfg_templets_skin/]/images/1.jpg"><em>[field:pingfen/] Points</em>                                       </b>                                   </Li>{/dede:arclist}

We will rewrite him with SQL statements, at this point we have to query the table has dede_archivies (Main table) and Dede_addonmovie (additional table) inside the information, the additional table inside the aid and the ID of the main table can be associated.

We first try to make a statement in the DOS window and see if we can do it normally:

Select  from  Left Join  on t1.id=t2.aid;

We can easily see here that it is really effective:

After our test success we can directly copy to just that directly use, as follows:

{dede:sql sql= "select T1.litpic, T1.title, T2.yuyan, t2.pingfen from Dede_archives T1 left joins Dede_addonmovie T2 on T1.id=t2.aid "}<Liclass= "c[field:global.autoindex/]">                                       <ahref= "http://www.a67.com/movie/7989"Target= "_blank">                                           <imgsrc= "[field:litpic/]"alt= "[field:title/] 3GP MP4 HD Download" />                                       </a>                                       <P>[field:yuyan/]</P>                                       <b>                                           <ahref= "http://www.a67.com/movie/7989"Target= "_blank">[field:title/]</a>                                           <imgsrc= "[Field:global.cfg_templets_skin/]/images/1.jpg"><em>[field:pingfen/] Points</em>                                       </b>                                   </Li>{/dede:sql}

Then we update the template of the Ere page in the background, and then open the website to see the effect as follows:

Is the same as can be done .....

However, it is important to note that in the SQL tag, although he is very flexible, but there are many times there is no Dede packaged library inside the label strong.

But if you want to make the SQL tag more powerful, you can also rewrite the SQL tag, where he is:

We are still talking about the topic, we now use the SQL tag to take out today's published information, the code is as follows:

The pubdate here means a field in our Dede_archives (the main table of the article), because this field stores the timestamp we posted:

Then we update the template of the Ere page in the background, we can look at the homepage to find the change:

Kill lui lei Dog---dedecms----18dedecms of the helpless label-sql tag Remove today update

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.