Search code examples
phppdocassandracassandra-2.0

Cassandra PDO connection PHP


I've got Cassandra working nicely on Debian server however I'm hoping to connect to it from a PHP application.

Currently it seems PDO it the way to go for anything complex as I'm able to use CQL. I'm using the latest forked version of the Apache Cassandra-PDO project.

I'm using the latest Cassandra 2.03 and I can connect to it fine from CQLSH in the terminal. When I try and connect in PHP using the following code

$db_handle = new PDO("cassandra:host=localhost;port=9160");

I get the following error

Fatal error: Uncaught exception 'PDOException' with message 'CQLSTATE[08006] [8]     TTransportException: Transport not open' in /var/www/index.php:9 Stack trace: #0 /var/www/index.php(9): PDO->__construct('cassandra:host=...') #1 {main} thrown in /var/www/index.php on line 9

I've seem a few issues alike on the internet, but no solutions as yet. Hopefully someone can provide some insight into the issue here.


Solution

  • Error 8006 is connection failure. I think you need login and password in PDO Statment like this: $pdo = new PDO('mysql:host=localhost;dbname=products', 'root', 'root');