Hi I am new to cassandra database. I am trying to do a project in codeigniter with cassandra database. I have downloaded the phpcassandra files through below link https://github.com/mauritsl/php-cassandra.
When I am trying to autoload my casssandra.php in codeigniter I got Non-existent class: Cassandra error. Why I got this error and how to solve the issue?
You will need to create a wrapper for it if you wish to use it as a library.
I would suggest you take the composer route. You can check on packagist for a suitable library.
If you use this particular library phpcassa this is how you would go about getting it to work in Codeigniter.
{
"require": {
"php": ">=5.3.0",
"thobbs/phpcassa": "1.1.0"
}
}
require "../composer/autoload.php";
// Where codeigniter starts to load the Main Controller
// $cassandraDB will be in the GLOBAL scope, so you may want to write a wrapper
$cassandraDB = new ConnectionPool('localhost');
// Then right after this
// if (class_exists('CI_DB') AND isset($CI->db))
// {
// $CI->db->close();
// }
$cassandraDB->close();
implement it how you wish in your models
public function __construct()
{
//YOU MAY NEED TO PASS $cassandraDB AS A DEPENDANCY!!
$this->users = new ColumnFamily($cassandraDB, 'Standard1');
}