thobbs / phpcassa

PHP client library for Apache Cassandra
thobbs.github.com/phpcassa
MIT License
248 stars 78 forks source link

Phpcassa and float values #90

Closed lcosmin closed 12 years ago

lcosmin commented 12 years ago

I'm using cqlsh to create the following column family and insert a float value in it:

CREATE COLUMNFAMILY test
(
id varchar PRIMARY KEY, val float
)
WITH comparator = varchar AND default_validation = varchar;

INSERT INTO test (id, val) VALUES ('1', 2.45);

SELECT * FROM test;

id | val

----+------

  1 | 2.45

However, when I attempt to read the value from phpcassa, a weird result is returned:

$column_family='test';
$key = '1';

$pool = new ConnectionPool($keyspace, $servers);
$cf = new ColumnFamily($pool, $column_family);
$value = $cf->get($key);
print_r($value);

Array
(
    [val] => -428050432
)

I'm using the latest version phpcassa , commit 3f77c27c288943e2c093437f8677da57b346f87f on an Ubuntu x86_64 machine. Any idea why this is happening?

lcosmin commented 12 years ago

Any idea if this solution covers PHP running on big endian machines? I have a feeling for those the strrev won't be necessary (unfortunately I don't have such a machine at hand, to test).