mercredi 13 juillet 2016

PDO variables not working on sql limit code [duplicate]

This question already has an answer here: How bindValue in LIMIT? 8 answers I have been working on this problem for some time now and I don't seem to understand even after referencing other previously asked questions what I am doing wrong. Working Solution: $stmt = $dbh->prepare("SELECT * FROM tempTable ORDER BY id ASC LIMIT 1 , 7"); Non-Working Solution: $limit1 = 1; $limit2 = 7; $stmt = $dbh->prepare("SELECT * FROM tempTable ORDER BY id ASC LIMIT :start , :end"); $stmt->execute(array(':start' => $limit1, ':end' => $limit2)); I have never had an issue with pdo / sql using php before like this and apparently have no understanding of why this is occurring. Thanks for the help!

Aucun commentaire:

Enregistrer un commentaire