2015-11-27 14:56:20 4117次浏览 1条回答 0 悬赏 10 金钱
$sql = 'select * from xxx  where location_id in (:location_id)';
$location_id = '1003,1004,1005';
bindParam(':location_id', $location_id, PDO::PARAM_STR);

$location_id 这样后 sql查出的结果只有1003的结果,这是怎么回事,请指教。

  • 回答于 2015-11-27 15:49 举报

    如果这样能行的话....参数绑定就无法杜绝sql inject了....

    有几个参数 绑定几个..

    $locationIds = [1,2,3,4,5];
    $locationParams = str_repeat('?', count($locationIds));
    
    3 条回复
    回复于 2015-11-27 17:59 回复

    $locationParams = str_repeat('?', count($locationIds));

    这个没明白

    回复于 2015-11-28 13:32 回复

    意思就是你要 每个值都要绑定一个参数

    回复于 2015-12-02 07:23 回复

    能不能问下 每个值都要绑定怎么写 ??接着@bycall的问题。

您需要登录后才可以回答。登录 | 立即注册
bycall
经理

bycall

注册时间:2015-07-09
最后登录:2017-10-27
在线时长:7小时15分
  • 粉丝2
  • 金钱1040
  • 威望0
  • 积分1110

热门问题