1

I got a separate database using PostgreSQL and I want to access it via the WPDB class. I tried

$pgdb = new wpdb('[username]','[password]','[database]','localhost');
var_dump( $pgdb->get_results('SELECT table_name FROM information_schema.tables') );

but it's just showing a null value.

What is the proper way of accessing PostgreSQL using WPDB?

2
  • 1
    As far as I know, WordPress does not support PostgreSQL out of the box, and requires the use of things like PG4WP to use it as a database. Even then, I don't know for sure if you can use PG in tandem with MySQL. You might consider setting up an API for your PostgreSQL data that you can access from WP instead
    – phatskat
    Oct 19, 2015 at 14:55
  • PostgeSQL and MySQL are both similar, both being SQL, but the syntax is not identical, nor is database functionality. You are probably going to have to use built-in PHP functions to access the database, not WordPress one.
    – s_ha_dum
    Oct 19, 2015 at 15:43

0

Your Answer

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

Browse other questions tagged or ask your own question.