PHP syntax for postgresql Mixed-case table names

Posted by yam on Stack Overflow See other posts from Stack Overflow or by yam
Published on 2010-05-13T06:20:47Z Indexed on 2010/05/13 6:24 UTC
Read the original article Hit count: 176

Filed under:
|

I have a code below:

<?php
require "institution.php"
/* in this portion, query for database connection is executed, and  */

$institution= $_POST['institutionname'];

$sCampID =  'SELECT ins_id FROM institution where ins_name= '$institution' ';
$qcampID = pg_query($sCampID) or die("Error in query: $query." . pg_last_error($connection));
/* this portion outputs the ins_id */           
?>

My database before has no mixed-case table names, that's why when I run this query, it shows no error at all. But because I've changed my database for some reasons, and it contains now mixed-case table names, i have to change the code above into this one:

$sCampID =  'SELECT ins_id FROM "Institution" where ins_name= '$institution' ';

where the Institution has to be double quoted. The query returned parse error. When i removed this portion: where ins_name= '$institution', no error occured.

My question is how do I solve this problem where the table name which contains a mixed-case letter and a value stored in a variable ($institution in this case) will be combined in a single select statement?

Your answers and suggestions will be very much appreciated.

© Stack Overflow or respective owner

Related posts about php

Related posts about postgresql