下面这段程序的作用是,从数据库中获取一个数据列表。然后判断取出的数组有多少个,如果不足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);
}