Home  >  Article  >  CMS Tutorial  >  Imperial CMS’ method to implement efficient random calls

Imperial CMS’ method to implement efficient random calls

silencement
silencementforward
2019-11-26 15:32:222917browse

Imperial CMS’ method to implement efficient random calls

The example in this article describes the method of implementing efficient random calls in Imperial CMS. Share it with everyone for your reference. The specific implementation method is as follows:

The Empire CMS uses ORDER BY RAND() to make random calls, which is the most resource-intensive calling method. If the number of website information is too large, more than 10,000, random calls will affect the website speed.

If you really want to use it, you can use the following idea:

First use php to randomly generate the information ID, and then use SQL to call id in, and php will randomize the ID list.

Calling example:

The code is as follows:

<?php
$randnum=10; //随机数量
$randids=&#39;&#39;;
$randdh=&#39;&#39;;
for($i=1;$i<=$randnum;$i++)
{
$randids.=$randdh.rand(1,100000); //1为最小ID,100000为最大ID
$randdh=&#39;,&#39;;
}
?>
[e:loop={栏目ID,显示条数,操作类型,只显示有标题图片,"id in ($randids)"}]
//模板代码内容
[/e:loop]

Recommended to study "Empire cms tutorial"

I hope this article will be helpful to everyone's Imperial CMS website building help.

The above is the detailed content of Imperial CMS’ method to implement efficient random calls. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:www.word666.com. If there is any infringement, please contact admin@php.cn delete