Friday, 15 June 2012

sql - Postgres 'where' query is not working with PHP -



sql - Postgres 'where' query is not working with PHP -

i'm running php code trying find rows specified parameter. have connected database, i'm running 1 problem.

when run code:

$sql = "select * schema.table"; $result = pg_exec($dbconn, $sql); while ($row = pg_fetch_array($result) { echo "data: " .$row . "<br/>\n";

i printed list of arrays showing successful in taking info database , beingness able print out website page.

however, need filter info want rows specific id. when seek query:

$sql = "select * schema.table 'id' = '123'";

pg_numrows($result) 0 when there 4 rows id of 123 , there nil show , no array , have no thought why adding 'where' statement changes anything. happened data, why filtering cause no longer work?

solved: figured out reply running same problem.

$sql = "select * schema.table \"id\" = '123'";

this syntax must used character varying columns. making me realize running funny code wrong quotation marks.

use this..

$sql = "select * schema.table id = 123";

never utilize single quotes column names , never utilize single quotes int type..

php sql postgresql where

No comments:

Post a Comment