我在使用 DataStax php 驱动程序 1.0.0-rc 和 Cassandra 2.2.3 的 Prepared Statements 时遇到奇怪的错误。我在这条线上遇到了一个异常:
$statement = $this->session->prepare("SELECT ? FROM ? WHERE ? = ?");
我看到这个错误:
"error_code":33562624
"error_message":"Bind variables cannot be used for keyspace names"
在用于与 Cassandra 通信的类存根下方:
class ClsCassandra extends ClsDbObject
{
private $hostname="";
private $username="";
private $password="";
private $keyspace="";
private $poi_table="";
private $poi_table_key_field="";
private $poi_table_content_field="";
private $cluster = NULL;
private $session = NULL;
private $threads = 1;
function __construct()
{
...
...
//
// i set up all the properties above
//
...
...
}
public function runQuery(&$error)
{
try
{
$this->cluster = Cassandra::cluster()
->withContactPoints($this->hostname)
->withCredentials($this->username, $this->password)
->withIOThreads($this->threads)
->build();
$this->session = $this->cluster->connect($this->keyspace);
// error on next line...
$statement = $this->session->prepare("SELECT ? FROM ? WHERE ? = ?");
$results = $this->session->execute($statement, new Cassandra\ExecutionOptions(array(
'arguments' => array($this->poi_table_content_field, $this->poi_table, $this->poi_table_key_field, $keypattern)
)));
}
catch(Cassandra\Exception $ce)
{
$error->setError($ce->getCode(), $ce->getMessage(), $ce->getTraceAsString());
$this->log(LOG_LEVEL, $error->getErrorMessage(), __FILE__, __LINE__, __CLASS__);
return false;
}
return true;
}
...
...
...
}
如果我将 Simple Statemetn 与标准选择查询一起使用,则它可以工作。
有什么建议么?