php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39906 Unable to use place holders as part of the actual SQL query with PDO's
Submitted: 2006-12-20 16:31 UTC Modified: 2006-12-20 16:42 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: iab398 at bham dot ac dot uk Assigned:
Status: Not a bug Package: SQLite related
PHP Version: 5.2.0 OS: Unix
Private report: No CVE-ID: None
 [2006-12-20 16:31 UTC] iab398 at bham dot ac dot uk
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-20 16:42 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC