下面这段程序的作用是,从数据库中获取一个数据列表。然后判断取出的数组有多少个,如果不足15个,再以其它条件搜索出一些结果来补足15个。
$productModel = D('productView');
$osupplylist = $productModel->where("parkId=$parkId and proClass=1 and proGroup=1")->order("id desc")->limit(15)->select();
//补齐15个
if($osupplylist==null){
$osupplylist = $productModel->order("id desc")->limit(15)->select();
}else{
$count = count($osupplylist);
if($count<15){
$osupplylist_ext = $productModel->where("parkId<>$parkId and proClass=1 and proGroup=1")->order("id desc")->limit(15-$count)->select();
$osupplylist = array_merge($osupplylist,$osupplylist_ext);
}
}
要饭二维码
洪哥写文章很苦逼,如果本文对您略有帮助,可以扫描下方二维码支持洪哥!金额随意,先行谢过!大家的支持是我前进的动力!

文章的版权
本文属于“洪哥笔记”原创文章,转载请注明来源地址:php获取数组长度-count()函数:http://www.splaybow.com/post/php-get-array-length.html
如果您在服务器运维、网络管理、网站或系统开发过程有需要提供收费服务,请加QQ:8771947!十年运维经验,帮您省钱、让您放心!
亲,如果有需要,先存起来,方便以后再看啊!加入收藏夹的话,按Ctrl+D!
发布时间:2015/6/8 14:48:38 | 编辑:洪哥 | 分类:PHP | 浏览: