Skip to main content

Querying Vertica using PHP PDO PostgreSQL, is it possible?

  • January 3, 2014
  • 1 reply
  • 12 views

Kirill_Beloshit
Hello,

I'm on FreeBSD with PHP. As I mentioned in this topic - https://community.vertica.com/vertica/topics/odbc_driver_for_freebsd I was unable to find solution to use Vertica ODBC driver with FreeBSD. So, now I'm looking for another ways to query Vertica from PHP.

In this stackoverflow topic http://stackoverflow.com/questions/13327948/connecting-to-a-vertica-db-with-php/13394911#13394911 @deadrunk told that it is possible to use Postgres client libs to connect Vertica.

I've tried using pgsql for PDO. Connection is ok, but querying seems to be faild with no errors. Do anybody know any information about how to do it properly? Here is the piece of code I was using:
$PDO = new \PDO('pgsql:dbname=mydb;host=myhost;port=5433', 'dbadmin', 'test');  $sth = $PDO->prepare('SELECT table_name FROM tables');  $sth->execute();  $result = $sth->fetch(\PDO::FETCH_ASSOC);  print_r($result);
Result contains nothing.
PS: I'm very sorry, I'm pretty new to Vertica.

Thank you!

1 reply

Prasanta_Pal
Forum|alt.badge.img
  • Participating Frequently
  • January 4, 2014
See the link for more details on PHP PDO
https://my.vertica.com/docs/6.1.x/HTML/index.htm#16510.htm

check if ODBC conection using isql to see if it is returning any rows