Hello Thies, Friday, March 25, 2005, 1:55:30 PM, you wrote:
> 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";-) We could easily add this behavior and i think it makes somewhat sense. It just looks a bit like __wakepup/__sleep. The only 'but' is that i suggest the behavior has its own method like 'bindParamArray'. If you cannot work out a patch feel free to contact me. Maybe i'll find some time during the conf. -- Best regards, Marcus mailto:[EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php