Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15594 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89575 invoked by uid 1010); 25 Mar 2005 11:55:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 89560 invoked from network); 25 Mar 2005 11:55:41 -0000 Received: from unknown (HELO m.gmane.org) (127.0.0.1) by localhost with SMTP; 25 Mar 2005 11:55:41 -0000 X-Host-Fingerprint: 80.91.229.2 main.gmane.org Linux 2.4/2.6 Received: from ([80.91.229.2:59784] helo=ciao.gmane.org) by pb1.pair.com (ecelerity HEAD r(5268)) with SMTP id 00/01-61605-C3CF3424 for ; Fri, 25 Mar 2005 06:55:40 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DEnPM-0004nx-Ac for internals@lists.php.net; Fri, 25 Mar 2005 12:55:20 +0100 Received: from dsl-084-059-201-234.arcor-ip.net ([84.59.201.234]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 Mar 2005 12:55:20 +0100 Received: from thies by dsl-084-059-201-234.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 Mar 2005 12:55:20 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: internals@lists.php.net Date: Fri, 25 Mar 2005 12:55:30 +0100 Lines: 51 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: dsl-084-059-201-234.arcor-ip.net User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) X-Accept-Language: en-us, en Sender: news X-Gmane-MailScanner: Found to be clean X-Gmane-MailScanner: Found to be clean X-MailScanner-From: php-php-dev@m.gmane.org X-MailScanner-To: internals@lists.php.net Subject: pdo: binding variables supplied to execute() is NotVeryUseful(tm)... From: thies@thieso.net ("Thies C. Arntzen") hi, pdo hat it's own query-parser, named variables are prefixed with a colon... so far - so nice... i have a function called insert which is called like this: $db->insert('some_table', array('name' => $name, 'age' => $age)); it's implemented like this: function insert($table, $values) { $column_names = array_keys($values); $col_list = implode(', ', $column_names); $bind_list = implode(', :', $column_names); $sql = "insert into $table ($col_list) values ($bind_list)"; $stmt = $this->prepareStatement($sql); // works: // this is how it has to be done.. // foreach ($values as $col => $val) { $stmt->bindParam(":$col", $values[ $col ]); } $stmt->execute(); // doesn't work // and this is how i would like it instead // # $stmt->execute($values); } and this is 'cause pdo _expects_ the user to prefix the bound variables with a colon. grr... ppls, lets change it before it's too late. this "tiny bit" makes binding harder than it should be, and we all know and understand that all user of php should use bound variables all the time! suggestion: auto-trim a leading colon from the internal binding tables. that way "oldish" code would not break... re, thies PS: looking into that right now - hopefully "patch follows";-)