I use Cassandra-PHP-Client-Library library for get/set data to Apache Cassandra. I created a keyspace name via cqlsh coomanda line:
CREATE TABLE employees (
company text,
name text,
age int,
role text,
PRIMARY KEY (company,name)
);
Then have inserted some columns also via command line:
INSERT INTO employees (company, name, age, role) VALUES ('OSC', 'eric', 38, 'ceo');
INSERT INTO employees (company, name, age, role) VALUES ('OSC', 'john', 37, 'dev');
Now I try insert any data from php, for this i use method set() of library:
$this->cassandra->set(
'employees.company',
array(
'company' => '[email protected]',
'name' => 'Alice Rozenberg',
'age' => 45,
'role' => 'ddd'
)
);
In the official manual was told that first param of function set() is key row (employees is a name of column family, company is a key), and other - are name and value of columns. In this regard, I have a few questions:
What is a row key in my case? At the "CREATE" command I specifed, that primary key is "company,name". But this not correct for use in function. This option does not work:
$this->cassandra->set(
'employees.name',
...
$this->cassandra->set(
'employees.company',
...
I change to phpcassa library and have question about composites types:
From tutorial example: https://github.com/thobbs/phpcassa/blob/master/examples/composites.php
// Insert a few records
$key1 = array("key", 1);
$key2 = array("key", 2);
$columns = array(
array(array(0, "a"), "val0a"),
array(array(1, "a"), "val1a"),
array(array(1, "b"), "val1b"),
array(array(1, "c"), "val1c"),
array(array(2, "a"), "val2a"),
array(array(3, "a"), "val3a")
);
Who can me tell, what composire array will be in my case for two row keys "name, company"? Thank you!