Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22926 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70099 invoked by uid 1010); 22 Apr 2006 14:35:51 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 70084 invoked from network); 22 Apr 2006 14:35:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Apr 2006 14:35:51 -0000 X-Host-Fingerprint: 64.233.166.177 pproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.166.177:47382] helo=pproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 3E/D5-19715-64F3A444 for ; Sat, 22 Apr 2006 10:35:50 -0400 Received: by pproxy.gmail.com with SMTP id 57so740486pya for ; Sat, 22 Apr 2006 07:35:47 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=sRy9oB+XrNrENnrSMrS4urAvEoSUt0MUuSmqpkQeEYbiLFJDOTSKegyHKl5XS/s0PtJdqdLY1xVaSothXoc4e7Wm5DgO/+ac0vCZH6fSupNO/fK2s+cTuAsv5Th9+Zl4VMLj2v43Lzw9ht99reiTFQrutAAZTxn8fM7XKrfjK28= Received: by 10.35.50.9 with SMTP id c9mr1429807pyk; Sat, 22 Apr 2006 07:35:46 -0700 (PDT) Received: by 10.35.41.17 with HTTP; Sat, 22 Apr 2006 07:35:46 -0700 (PDT) Message-ID: <4e89b4260604220735y300ed126j306334021628a240@mail.gmail.com> Date: Sat, 22 Apr 2006 10:35:46 -0400 To: "Ralph Schindler" Cc: internals@lists.php.net In-Reply-To: <4449B766.50109@smashlabs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4449B766.50109@smashlabs.com> Subject: Re: [PHP-DEV] PDO MySQL - show create table From: kingwez@gmail.com ("Wez Furlong") You need to do this: $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); before you call $db->prepare(). hint: if you did this: $db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); (see http://us2.php.net/manual/en/ref.pdo.php#pdo.error-handling) you'd get an exception: 'SQLSTATE[HY000]: General error: 2030 This command is not supported in the prepared statement protocol yet' --Wez. On 4/22/06, Ralph Schindler wrote: > 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=3Dxxxxxx 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=3DInnoDB DEFAULT CHARSET=3Dutf8 > > > #### THE TEST SCRIPT > > ralph@localhost ~/development/code/php5.1-200604220230 $ cat > /home/ralph/development/vhosts/ralphschindler.com/development/test_show.p= hp > > $db =3D new PDO("mysql:dbname=3Dtest", "root", "xxxxxx"); > > echo "\nTEST PREPARED-------\n"; > > try { > $stmt =3D $db->prepare("SHOW CREATE TABLE blog_comments"); > $stmt->execute(); > print_r($stmt); echo "\n"; > $result =3D $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 =3D $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.p= hp > > TEST PREPARED------- > PDOStatement Object > ( > [queryString] =3D> SHOW CREATE TABLE blog_comments > ) > > Array > ( > ) > no exceptions > > > TEST QUERY-------- > > no exception > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >