php-cassandra-binary
php-cassandra-binary copied to clipboard
returns garbage when querying multiple rows
hi, I'm trying this lib with cassandra 2.1.1 Maybe there is a cql protocol change, because I can't get a simple query that returns multiple rows to return the correct data. Maybe the NULL value is a problem?
in cqlsh:
cqlsh:testkeyspace> insert into animals(name,species,genus,family) values('pippi','dog', 'male','tiger');
cqlsh:testkeyspace> insert into animals(name,species,genus,family) values('pippi2','dog', 'male','tiger');
cqlsh:testkeyspace> select * from animals;
name | family | genus | species | subspieces
--------+--------+-------+---------+------------
pippi | tiger | male | dog | null
pippi2 | tiger | male | dog | null
In php:
$database = new evseevnn\Cassandra\Database($nodes, 'testkeyspace');
$database->connect();
$user2 = $database->query('SELECT * FROM animals ');
var_dump($user2);
result:
array(2) {
[0]=>
array(5) {
["name"]=>
string(5) "pippi"
["family"]=>
string(5) "tiger"
["genus"]=>
string(4) "male"
["species"]=>
string(3) "dog"
["subspieces"]=>
string(37) "pippi2tigermaledog���"
}
[1]=>
array(5) {
["name"]=>
NULL
["family"]=>
NULL
["genus"]=>
NULL
["species"]=>
NULL
["subspieces"]=>
NULL
}
}
I am investigating right now and it is definitely caused by null value types that are not handled correctly at the moment.
for your information, I switched to the duoshuo/php-cassandra library now. It is also using native socket communication on CQL 3 level, but it seems a bit more mature now. It also supports async calls.
@rvwoens Have fun using collections then, they are definitely broken in the duoshuo one. We fixed the null value issue in https://github.com/eyeem/php-cassandra-binary already and the PR is just a matter of writing tests first. I think we also have better timeout handling and in general have tests to avoid breaking features in the future. Anyway, it's your decision, just my 2 cents on the different libraries and what I discovered so far. Maybe you want to rethink your decision :)
What do I need to put in composer.json to get this version? https://github.com/eyeem/php-cassandra-binary
I've get the fixed files manually by getting update these files (BinaryData.php, DataStream.php) and the null values as been fixed but I want it to be in the composer, I've try: "eyeem/php-cassandra-binary" : "dev-master"
Thanks!
@LarsFronius @rvwoens May this incompatible change in PHP 5.5.0's unpack function explain the bug?
@CBox Please open a new issue for your problem/question. This one is about a bug on query return values, not composer dependency fixing.