添加用户登录账号条件(支持尾号搜索)
$sql ="select group_concat(id) from `user` where `user_name` like '%".trim($user_name)."%'";
$ids = $GLOBALS['db']->getOne($sql);
if($ids)
$conditon .= " and uid in ($ids) ";
else
$conditon .= " and uid >0 ";
$res = db('database')->where($condition)->select();
思路:用trim函数去掉搜索关键字两边的空格、换行符等,再用模糊搜索。