Answer the question
In order to leave comments, you need to log in
Phpcassa library - why does an error occur every time - with details?
Table structure:
CREATE TABLE posts_user (
post_id bigint,
post_at timestamp,
user_id bigint,
PRIMARY KEY ((post_id), post_at)
)
WITH CLUSTERING ORDER BY (post_at DESC) AND COMPACT STORAGE;
<?php
require_once(__DIR__.'/phpcassa/lib/autoload.php');
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;
class Cassandra {
public $c;
function __construct() {
$pool = new ConnectionPool('<b>feed</b>', array('127.0.0.1:9160'));
$this->c = new ColumnFamily($pool, '<b>posts_user</b>');
}
public function insert(){
$num = rand(1, 500);
$this->c->insert($num, array('post_at' => time(), 'user_id' => '1')); //Здесь возникает ошибка при добавлении
//$results = $this->c->get("1");
}
}
?>
cqlsh:feed> INSERT INTO posts_user (post_at, user_id, post_id) VALUES (1408827330, 3, 169);
Fatal error: Uncaught exception 'cassandra\InvalidRequestException' in /home/who/public_html/application/libraries/phpcassa/lib/Thrift/Base/TBase.php:206 Stack trace: #0 /home/who/public_html/application/libraries /phpcassa/lib/cassandra/Cassandra.php(3859): Thrift\Base\TBase->_read('Cassandra_batch...', Array, Object(Thrift\Protocol\TBinaryProtocolAccelerated)) #1 /home/who/public_html/ application/libraries/phpcassa/lib/cassandra/Cassandra.php(939): cassandra\Cassandra_batch_mutate_result->read(Object(Thrift\Protocol\TBinaryProtocolAccelerated)) #2 /home/who/public_html/application/libraries/phpcassa/lib/ cassandra/Cassandra.php(901): cassandra\CassandraClient->recv_batch_mutate() #3 [internal function]: cassandra\CassandraClient->batch_mutate(Array,1) #4 /home/who/public_html/application/libraries/phpcassa/lib/phpcassa/Connection/ConnectionPool.php(264): call_user_func_array(Array, Array) #5 /home/who/public_html/application/libraries/phpcassa /lib/phpcassa/AbstractColumnFamily.php(686): phpc in /home/who/public_html/application/libraries/phpcassa/lib/Thrift/Base/TBase.php on line 206
// File TBase.php:206
$this->$var = new $class();
// Переменная $class - \cassandra\KsDef187\cassandra\InvalidRequestException
[cqlsh 4.1.1 | Cassandra 2.0.9 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Answer the question
In order to leave comments, you need to log in
something prompts to me that a problem in a connection... at new ConnectionPool connection is not created yet. the connection is initialized when the insert itself passes
and since the connection cannot be initialized, it falls with the exception
use native protocol and CQL https://code.google.com/a/apache-extras.org/p/cass... or any other from www.planetcassandra.org/client-drivers-tools/#PHP and don't suffer
in general, there are bugs in Cassandra when a table was created by a trick and is used natively, the same when inserting data, those data are inserted by a trick into a table created from CQL or vice versa. You can see not all created fields, etc. Trift is considered an obsolete protocol and it is RECOMMENDED NOT to USE
ie. it is necessary to use either only a trift or only a native, otherwise there will be a solid rake and stones. And since there are no tools for the trift, you shouldn’t use it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question