note 91083 added to function.pg-query-params
| From: | strata_ranger at hotmail dot com | Date: | Sun, 24 May 2009 16:03:17 +0000 |
| Subject: | note 91083 added to function.pg-query-params | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-155924@lists.php.net to get a copy of this message | ||
Regarding boolean values, just typecast them as (integer) when passing them in your query --
'0' and '1' are perfectly acceptable literals for SQL boolean input:
- http://www.postgresql.org/docs/8.2/interactive/datatype-boolean.html
It is also safe to write your paramerized query in double-quotes, which allows you to mix constant
values and placeholders in your query without having to worry about how whether PHP will attempt to
substitute any variables in your parameterized string.
Of course this also means that unlike PHP's double-quoted string syntax, you CAN include
literal $1, $2, etc. inside SQL strings, e.g:
<?php
// Works ($1 is a placeholder, $2 is meant literally)
pg_query_params("INSERT INTO foo (col1, col2) VALUES ($1, 'costs $2')",
Array($data1));
// Throws an E_WARNING (passing too many parameters)
pg_query_params("INSERT INTO foo (col1, col2) VALUES ($1, 'costs $2')",
Array($data1, $data2));
?>
----
Server IP: 69.147.83.197
Probable Submitter: 76.2.25.104
----
Manual Page -- http://www.php.net/manual/en/function.pg-query-params.php
Edit -- https://master.php.net/note/edit/91083
Del: integrated -- https://master.php.net/note/delete/91083/integrated
Del: useless -- https://master.php.net/note/delete/91083/useless
Del: bad code -- https://master.php.net/note/delete/91083/bad+code
Del: spam -- https://master.php.net/note/delete/91083/spam
Del: non-english -- https://master.php.net/note/delete/91083/non-english
Del: in docs -- https://master.php.net/note/delete/91083/in+docs
Del: other reasons-- https://master.php.net/note/delete/91083
Reject -- https://master.php.net/note/reject/91083
Search -- https://master.php.net/manage/user-notes.php