A universal function that imitates a universal tag//Generates a parameter list and returns it in the form of an array<br>
function mt_toarray($tag = ''){<br>
$param = array();<br>
$array = explode(';',$tag);<br>
foreach ($array as $v){<br>
list($key,$val) = explode(':',trim($v));<br>
$param[trim($key)] = trim($val);<br>
}<br>
Return $param;<br>
}<br>
function getlist($tag){<br>
$list = array();<br>
$tag = mt_toarray($tag);<br>
$model =!empty($tag['model'])?$tag['model']:'';<br>
$limit =!empty($tag['limit'])?$tag['limit']:'10';<br>
$order =!empty($tag['order'])?$tag['order']:'';<br>
$field =!empty($tag['field'])?$tag['field']:'*';<br>
If($model == ""){return $list;}<br>
$M=M($model);<br>
If(!empty($tag['where'])){<br>
$wheres = explode(',',$tag['where']);<br>
foreach($wheres as $v){<br>
If(!empty($tag[$v])){<br>
$where[$v] = array('in',$tag[$v]);<br>
}<br>
}<br>
$M->where($where);<br>
}<br>
$list = $M->field($field)->order($order)->limit($limit)->select();<br>
Return $list;<br>
}
Usage example<php>$list = getlist("model:article;where:cid;cid:1,2,3,4");</php>
The above paragraph is to get the cid in the article table The content of 1, 2, 3, and 4 is 10 by default
To write the template, just use the official circular writing method<php>$list = getlist("model:article;where:cid;cid:1,2,3,4");</php>
I am not a professional, please understand. If you have the ability, you can add page and other functions yourself.
{$vo.id}:{$vo.name}