PDO MySQL - show create table
| From: | Ralph Schindler | Date: | Sat, 22 Apr 2006 04:56:06 +0000 |
| Subject: | PDO MySQL - show create table | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-22924@lists.php.net to get a copy of this message | ||
Is it not possible to run the "show create table __" via PDO? I swear I was able to do this in the past, and for some reason this is not working. Am I doing something wrong, is this a bug, or is this planned?
Pasted below is the mysql command and result expected, test code, and its result.
-ralph
#### PROOF THE COMMAND WORKS
ralph@localhost ~/development/code/php5.1-200604220230 $ echo "show create table blog_comments" | mysql -u root --password=xxxxxx test
Table Create Table
blog_comments CREATE TABLE
blog_comments (\n id int(11) NOT NULL auto_increment,\n blog_entry_id int(11) NOT NULL,\n comment text NOT NULL,\n comment_datetime datetime NOT NULL,\n PRIMARY KEY (id),\n KEY FK_blog_comments_1 (blog_entry_id),\n CONSTRAINT FK_blog_comments_1 FOREIGN KEY (blog_entry_id) REFERENCES blog_entries (id) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8
#### THE TEST SCRIPT
ralph@localhost ~/development/code/php5.1-200604220230 $ cat /home/ralph/development/vhosts/ralphschindler.com/development/test_show.php
<?
$db = new PDO("mysql:dbname=test", "root", "xxxxxx");
echo "\nTEST PREPARED-------\n";
try {
$stmt = $db->prepare("SHOW CREATE TABLE blog_comments");
$stmt->execute();
print_r($stmt); echo "\n";
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($result);
echo "no exceptions\n";
} catch (Exception $e) {
echo $e->getMessage();
echo "exception";
}
echo "\n\nTEST QUERY--------\n";
try {
$thing = $db->query("SHOW CREATE TABLE blog_comments");
print_r($thing); echo "\n";
echo "no exception\n";
} catch (Exception $e) {
echo $e->getMessage();
echo "exception";
}
#### TEST SCRIPT OUTPUT
ralph@localhost ~/development/code/php5.1-200604220230 $ ./sapi/cli/php /home/ralph/development/vhosts/ralphschindler.com/development/test_show.php
TEST PREPARED-------
PDOStatement Object
(
[queryString] => SHOW CREATE TABLE blog_comments) Array ( ) no exceptions TEST QUERY-------- no exception