php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43775 PDO can't handle prepared SHOW TABLES statements
Submitted: 2008-01-07 03:52 UTC Modified: 2008-01-07 10:31 UTC
From: adrianamustdie at yahoo dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.5 OS: openSuSE 10.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: adrianamustdie at yahoo dot com
New email:
PHP Version: OS:

 

 [2008-01-07 03:52 UTC] adrianamustdie at yahoo dot com
Description:
------------
a prepared statement used in a class.

$this->mysql == mysql connection
$database == name of the database

Reproduce code:
---------------
example #1 (work):
$stmt = $this->mysql->prepare("SHOW TABLES FROM ".$database);
$stmt->execute();

example #2 (don't work):
$stmt = $this->mysql->prepare("SHOW TABLES FROM ?");
$stmt->execute(array($database));

Expected result:
----------------
both examples should work!

Actual result:
--------------
error: 42000 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''databasename'' at line 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-07 10:31 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

That's a limitation inside MySQL. But you can use a query like
  SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '?'
instead.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 15 10:01:31 2024 UTC