数据查询时bind()会把整数值变成带单引号的值,怎么办

浏览:344 发布日期:2016/06/22 分类:求助交流 关键字: bind
$db = M("Activity");

//组合查询条件
$where ="is_show = :is_show and is_del= :is_del and title like :title";
//如果存在旧的轮播,将排除
if($old_article_id){
$where .= " and activity_id not in (:activity_id)";
$str = "";
foreach($old_article_id as $v){
$str .= "{$v},";
}
$bind[":activity_id"]= rtrim($str,",");
}
//查出显示、没有删除、开启、
$bind[":is_show"] = 1;
$bind[":is_del"] = 0;

$bind[":title"] = "%{$advertising_title}%";
$lists = $db ->where($where)->bind($bind)->field("title,activity_id as article_id")->order("insert_time desc")->select();


SELECT `title`,activity_id as article_id FROM `ra_activity` WHERE ( is_show = '1' and is_del= '0' and
title like '%捐%' and activity_id not in ('12,11,14,15') ) ORDER BY insert_time desc
最佳答案
评论( 相关
后面还有条评论,点击查看>>