How to apply bindValue method in LIMIT clause?

后端 未结 10 2380
旧巷少年郎
旧巷少年郎 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:12

    Looking at the bug report, the following might work:

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

    but are you sure your incoming data is correct? Because in the error message, there seems to be only one quote after the number (as opposed to the whole number being enclosed in quotes). This could also be an error with your incoming data. Can you do a print_r($_GET); to find out?

提交回复
热议问题