How to apply bindValue method in LIMIT clause?

后端 未结 10 2382
旧巷少年郎
旧巷少年郎 2020-11-21 04:28

Here is a snapshot of my code:

$fetchPictures = $PDO->prepare(\"SELECT * 
    FROM pictures 
    WHERE album = :albumId 
    ORDER BY id ASC 
    LIMIT :s         


        
10条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-21 05:30

    for LIMIT :init, :end

    You need to bind that way. if you had something like $req->execute(Array()); it wont work as it will cast PDO::PARAM_STR to all vars in the array and for the LIMIT you absolutely need an Integer. bindValue or BindParam as you want.

    $fetchPictures->bindValue(':albumId', (int)$_GET['albumid'], PDO::PARAM_INT);
    

提交回复
热议问题