|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-12-20 16:42 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 12:00:01 2025 UTC |
Description: ------------ Example within a PHP context: /* using sqlite 3 database SQLLDB is a define() path to the database location elsewhere */ if (!($db = new PDO('sqlite:' . SQLLDB))) { $error = $db->errorInfo(); die($error[2]); } /* the direction in which to order the query */ $direction = "ASC"; $query = $db->prepare('SELECT * FROM table_name ORDER BY value :dir'); $query->bindParam(':dir', $direction, PDO::PARAM_STR, 4); $query->execute(); Here, a error stating that the prepare() failed occurs due to acting on a non-object. Would it be possible to maybe allow place holders for actual parts of the SQL query, rather than just values? Cheers Reproduce code: --------------- as above. Expected result: ---------------- for the data to be retrieved from the database and ordered either ASC or DESC according to the value of $direction Actual result: -------------- PDO/SQLite error. As above.