0

I have database name "TestDB" and under that I have table called "User". Above TestDB database and User table have been created in both mysql and postgres.

I have written the following code. it is working for mysql & not working for postgres.

/* The below code is show the output as array with currentuser key value property / (this is if we execute directly @ postgres prompt it will give the current user query result/ not the actual table located inside the Testdb */

php code

     include('adodb/adodb.inc.php');

     $db = ADONewConnection("mysql"); # eg 'mysql' or 'postgres'

     $db->debug = true;

     $db->Connect(localhost, "mysql", "mysql123","TestDB");

     $rs = $db->Execute('select * from User');

     print "<pre>";

     print_r($rs->GetRows());

     print "</pre>";

     $db1 = ADONewConnection("postgres"); # eg 'mysql' or 'postgres'

     $db1->debug = true;

     $db->Connect(localhost, "postgres", "postgres123","TestDB");

     $rs = $db->Execute('select * from User');

     print "<pre>";

     print_r($rs->GetRows());

     print "</pre>";

Please suggest me what to do this.

1
  • I think you posted the same code snippets twice? Commented Oct 22, 2013 at 6:48

1 Answer 1

1

As answered here, PostgreSQL defaults to lower case characters while being case sensitive with column and table names.

After the PostgreSQL connection, you could try the following:

$rs = $db->Execute('select * from "User"');
Sign up to request clarification or add additional context in comments.

5 Comments

fine. it worked. But in this case I can't write single code for mysql as well as postgressql. is it ? how to resolve that?
You could use only lower case in column and table names.
Now I have used only lowercase letters for database,tablename,columns. still it is not displaying respective table user
That is always tricky. Instead do you have consider to use some kind of ORM library, as RedBean? Or a full framework, as Laravel?
yes it is working now. i recreated all the database names,tables,column names in lowercase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.