duoshuo / php-cassandra

php Cassandra driver which support Protocol v3 (Cassandra 2.1) and asynchronous requests
MIT License
153 stars 53 forks source link

Unexpected result #53

Closed Zemistr closed 7 years ago

Zemistr commented 9 years ago

I have this table:

create table user (
    user_id uuid,
    user_activation_token uuid,
    user_status int,
    user_email varchar,
    user_timezone varchar,
    user_time_created timestamp,
    user_time_updated timestamp,
    user_time_last_login timestamp,
    primary key (user_id)
);

INSERT INTO user(
    user_id,
    user_activation_token,
    user_email,
    user_status,
    user_time_created,
    user_time_last_login,
    user_time_updated,
    user_timezone
)
 VALUES (
    798fc0e0-0b0e-11e5-9e5d-13eed59f735d,
    7f4fcc19-65c8-440f-8942-ed45c524dbc2,
    'me@zemistr.eu',
    0,
    1433710209253,
    0,
    0,
    'Europe/Prague'
);

but...

when I call "fetchRow()" I see this result:

array (size=8)
  'user_id' => string '798fc0e0-0b0e-11e5-9e5d-13eed59f735d' (length=36)
  'user_activation_token' => string '7f4fcc19-65c8-440f-8942-ed45c524dbc2' (length=36)
  'user_email' => string 'me@zemistr.eu' (length=13)
  'user_status' => int 0
  'user_time_created' => int -808867347
  'user_time_last_login' => int 0
  'user_time_updated' => int 0
  'user_timezone' => string 'Europe/Prague' (length=13)

I try v0.5.2 and dev-master...

pako-pl commented 9 years ago

What tool do you use to execute the INSERT command? What value do you see for the "user_time_created" field using cqlsh?

You might be doing something wrong when inserting the data into Cassandra (for example, if you use php-cassandra, you should pass the timestamp as new Cassandra\Type\Timestamp(1433710209253)).

Zemistr commented 9 years ago

I use Datastax DevCenter and clean CQL

pako-pl commented 9 years ago

I used cqlsh to run the INSERT statement and I got the correct integer value for "user_time_created" using php-cassandra. Tested using Cassandra 2.1.6.

Which version of Cassandra do you use? Version 2.1 or newer is required.

What happens if you use fetchAll() instead of fetchRow()?

Zemistr commented 9 years ago

I use: DevCenter 1.3.1 Cassandra 2.1.6

When I use fetchAll() I got the same result.

shen2 commented 9 years ago

64bit platform is required, you may used in 32bit platform

Zemistr commented 9 years ago

Yes, I use 32b PHP 5.6.8

pako-pl commented 9 years ago

Perhaps this information should be included in README.md? Currently it only says:

PHP 5.4+ is required.
Zemistr commented 9 years ago

:+1: In Readme.md and in composer.json

https://getcomposer.org/doc/02-libraries.md#platform-packages