php-cassandra-binary icon indicating copy to clipboard operation
php-cassandra-binary copied to clipboard

Fatal error: Class 'evseevnn\Cassandra\Database' not found in

Open anhphuong opened this issue 10 years ago • 2 comments

I'm starting try use this lib, but it have that error at index.php file My php is 5.5 My code here:

$nodes = [ 127.0.0.1' ]; try { // Connect to database. $database = new \evseevnn\Cassandra\Database($nodes, 'demodb'); $database->connect();

Please tell me how to fix!

Thanks

anhphuong avatar Sep 12 '15 05:09 anhphuong

Hi, I am new to cassadra and searching for the php driver and got this one after implementing this i also get the same error! I tries to write an auto loader using spl_autoload_register() but failed to meet the driver requirement and sudenly i found "Unavailable exception" in the issue section of this project and i sure that additional files required(vendor directory, use composer to get the directory)

mahana123 avatar Jan 17 '16 17:01 mahana123

After composer install command you will get a "vendor" directory then use this code


namespace evseevnn; include_once(DIR.DIRECTORY_SEPARATOR."vendor".DIRECTORY_SEPARATOR."autoload.php");

$nodes = [
    '127.0.0.1',
    '127.0.0.1:9042' => [
        'username' => '<user_name>',
        'password' => '<password>'
    ]
];

// Connect to database.
$database = new Cassandra\Database($nodes, '<keyspace>');
$database->connect();
// Run query.
$users = $database->query('SELECT * FROM "test"');
var_dump($users);

mahana123 avatar Jan 17 '16 17:01 mahana123