Php Codeigniter自动加载器isn';我不想去卡桑德拉图书馆
嗨,我是卡桑德拉数据库的新手。我是从 当我试图从application/config/autoload.php自动加载cassandra库时,我得到了不存在的类cassandra错误Php Codeigniter自动加载器isn';我不想去卡桑德拉图书馆,php,codeigniter,cassandra,Php,Codeigniter,Cassandra,嗨,我是卡桑德拉数据库的新手。我是从 当我试图从application/config/autoload.php自动加载cassandra库时,我得到了不存在的类cassandra错误 请帮助我解决此问题。o将所有与Cassandra相关的文件放入应用程序/库/文件夹 从每个Cassandra类文件中删除名称空间 “名称空间卡桑德拉;” 您的文件名和类名应该匹配,以便在codeigniter的自动加载函数中加载库 Cassandra文件类名称为“连接” 将类名更改为“Cassandra
请帮助我解决此问题。o将所有与Cassandra相关的文件放入应用程序/库/文件夹
- 从每个Cassandra类文件中删除名称空间
- 您的文件名和类名应该匹配,以便在codeigniter的自动加载函数中加载库
- 将类名更改为“Cassandra”
- 构造函数需要一个参数来连接数据库。加载自动加载库时无法传递参数
- 将构造函数方法名称更改为connect
- 使用$this->cassandra->connect($host,$keyspace,$options),您可以处理连接
/**
* Connect to Cassandra cluster.
*
* @param mixed $host
* Hostname as string or array of hostnames.
* @param string $keyspace
* @param array $options
*/
public function connect($host, $keyspace = NULL, $options = array()) {
$this->options += $options;
if (empty($host)) {
throw new InvalidArgumentException('Invalid host');
}
if (!is_array($host)) {
$host = array($host);
}
shuffle($host);
while ($host) {
$hostname = array_pop($host);
try {
$this->transport = new Transport($hostname, $this->options['connect_timeout'], $this->options['stream_timeout']);
break;
}
catch (Exception $e) {
if (empty($host)) {
// No other hosts available, rethrow exception.
throw $e;
}
}
}