kallaspriit / Cassandra-PHP-Client-Library

Cassandra PHP-based client library for managing and querying your Cassandra cluster
http://cassandra-php-client-library.com
103 stars 25 forks source link

how to insert longType key? #20

Open karmieom opened 12 years ago

karmieom commented 12 years ago

i created column family like as: create column family question with comparator=UTF8Type and default_validation_class=UTF8Type and key_validation_class= LongType and column_metadata=[{ column_name: userID, validation_class: UTF8Type, index_name:qestionUserID_idx, index_type:0}];

inserting is ok at cassandra-cli . set question[1]['userID']='user 001';

inserting is failed at PHP script: $cassandra->set( 'question.'.1, array( 'userID' => $_REQUEST['userID'], 'question' => $_REQUEST['question'], 'addedLocalTime' => $_REQUEST['questionDateTime'], 'added' =>$timestamp ) ); or $cassandra->cf('question')->set( 222 , array(
'userID' => $_REQUEST['userID'], 'question' => $_REQUEST['question'], 'addedLocalTime' => $_REQUEST['questionDateTime'], 'added' =>$timestamp ), Cassandra::CONSISTENCY_QUORUM );

I don't know what is not correct.

madhandennis commented 12 years ago

Could you post the error you are getting in here? Will be easier to find the issue that way.

karmieom commented 12 years ago

Thank you for response.

At cassdra-cli (insert is ok)

[default@Dokebee] create column family question2 with comparator=UTF8Type and default_validation_class=UTF8Type and key_validation_class= LongType; 5c6ed4ec-809b-33f8-838c-bf799b9e9d16 Waiting for schema agreement... ... schemas agree across the cluster

[default@Dokebee] set question2[1]['question']='what is cassandra'; Value inserted. Elapsed time: 3 msec(s).

[default@Dokebee] get question2[1]; => (column=question, value=what is cassandra, timestamp=1345768494170000) Returned 1 results. Elapsed time: 20 msec(s).

[default@Dokebee] create column family question3 with comparator=UTF8Type and default_validation_class=UTF8Type and key_validation_class= UTF8Type; 67436231-e56b-39fe-8ba7-cb9da959db4f Waiting for schema agreement... ... schemas agree across the cluster[[default@Dokebee] set question3['a']['question']='what is cassandra'; Value inserted. Elapsed time: 2 msec(s). [default@Dokebee] get question3['a']; => (column=question, value=what is cassandra, timestamp=1345768756291000) Returned 1 results. Elapsed time: 2 msec(s).

in PHP script

test1.php (insert at cf question3) ==> ok

<?php // show all the errors error_reporting(E_ALL);

// the only file that needs including into your project require_once 'lib/Cassandra.php'; include_once 'lib/connect.php';

// test UTF8Type key $key = "B"; $cassandra->set( 'question3.'.$key, array('question' =>'what is your problem2') ); $key = "C"; $cassandra->cf('question3')->set($key, array('question' =>'unknown2'));

?>

test2.php (insert at cf question2) ==> not working

<?php // show all the errors error_reporting(E_ALL);

// the only file that needs including into your project require_once 'lib/Cassandra.php'; include_once 'lib/connect.php';

// cf : question with longtype key echo "+++++++++++++
";

$num =(int)"4"; $cassandra->set( 'question2.'.$num, array('question' =>'what is your problem') );

$num =(int)"5"; $cassandra->cf('question2')->set($num, array('question' =>'unknown'));

?>

thank you

Erika Eom

On Thu, Aug 23, 2012 at 5:05 PM, Madhan Dennis notifications@github.comwrote:

Could you post the error you are getting in here? Will be easier to find the issue that way.

— Reply to this email directly or view it on GitHubhttps://github.com/kallaspriit/Cassandra-PHP-Client-Library/issues/20#issuecomment-7988489.

madhandennis commented 12 years ago

Hi, You still havent pasted the PHP exception you are getting when you run the PHP code above.

karmieom commented 12 years ago

sorry, i can't understand what you mean.

I just started cassandra & PHP a few weeks ago.

Please let me know how can i solve the problem.

thank you

Erika

On Thu, Aug 23, 2012 at 7:16 PM, Madhan Dennis notifications@github.comwrote:

Hi, You still havent pasted the PHP exception you are getting when you run the PHP code above.

— Reply to this email directly or view it on GitHubhttps://github.com/kallaspriit/Cassandra-PHP-Client-Library/issues/20#issuecomment-7990365.