![PikPak安卓最新版APP v1.46.2_免费会员兑换邀请码【508001】可替代115网盘_全平台支持Windows和苹果iOS&Mac_ipad_iphone -云主机博士 第1张 PikPak安卓最新版APP v1.46.2_免费会员兑换邀请码【508001】可替代115网盘_全平台支持Windows和苹果iOS&Mac_ipad_iphone -云主机博士 第1张](https://www.yunzhujiboshi.com/zb_users/upload/2022/06/202206281656381457152123.png)
phpcms V9调用多个模型中的最新内容的解决方法 -云主机博士
![PikPak安卓最新版APP v1.46.2_免费会员兑换邀请码【508001】可替代115网盘_全平台支持Windows和苹果iOS&Mac_ipad_iphone -云主机博士 第1张 PikPak安卓最新版APP v1.46.2_免费会员兑换邀请码【508001】可替代115网盘_全平台支持Windows和苹果iOS&Mac_ipad_iphone -云主机博士 第1张](https://www.yunzhujiboshi.com/zb_users/upload/2022/06/202206281656381457152123.png)
很多时候,希望调用多个模型下的最新内容,但是因为V9的模型使用分表储存,使用GET来IN catid却要连表查询十分麻烦,所以使用下面的办法即可搞定:
第一步:
phpcms\libs\functions\extention.func.php
里面增加
function news(limit="",limit="",limit="",modelid="",ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: where="")
{db=pc_base::load_model('content_model');
if((strpos(ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: …d,",")>=0))
{modelid=explode(",",modelid);modelid);modelid);midarr=dot=′′;foreach(dot='';
foreach(dot=′′;foreach(modelid as ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: mid)
{midarr=midarr.midarr.midarr.dot.mid;mid;mid;dot=',';
}
ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: …`modelid` IN ({midarr})";
}
else
{
ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: sq="`modelid`={modelid}";
}
db−>tablename=′v9model′;db->table_name='v9_model';db−>tablename=′v9model′;models=db−>select(db->select(db−>select(sq,"tablename");
sql=′′;sql='';sql=′′;lianhe='';
foreach(modelsasmodels asmodelsasname)
{
sql=sql=sql=sql.ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: …ttime FROM v9_{name['tablename']}";
ParseError: KaTeX parse error: Expected 'EOF', got '}' at position 25: …UNION ALL ';
}̲time=time();
sql=sql=sql=sql." ".where."orderbyinputtimedesclimit".where." order by inputtime desc limit ".where."orderbyinputtimedesclimit".limit;
allnews=allnews=allnews=db->query(sql);while(sql);
while(sql);while(r = db−>fetcharray(db->fetch_array(db−>fetcharray(allnews))
{
if(ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: keyfield)
{key = r[r[r[keyfield];
array[array[array[key] = ParseError: KaTeX parse error: Expected 'EOF', got '}' at position 7: r;
}̲
else
{array[] = ParseError: KaTeX parse error: Expected 'EOF', got '}' at position 7: r;
}̲
}
returnarray[0];
}
以上代码需要注意的是里面表前缀,这里是V9,使用的时候改成你自己的表前缀,默认是V9
第二步:
调用的方式为:
<?php $recent=news(“0,8“,”1,12“);?>
{loop recent recent recent r}
<li><a href=”{ParseError: KaTeX parse error: Expected 'EOF', got '}' at position 9: r[‘url’]}̲” target=”_blan…r[‘title’]}”>{str_cut($r[title],54,”)}</a></li>
{/loop}
{/pc}
解释:
红色数字是调用条数,从0开始调用8条
蓝色数字模型ID,不是栏目的ID,多个模型用,分开
![iproyal.png iproyal.png](https://pawns.iproyal.com/img/b/728.jpg)