Permalink
Browse files

get(x,y) works for non super column families, and insert(x) takes mul…

…tiple keys
  • Loading branch information...
1 parent 91d05c8 commit a9985d3f0c8a2935a0da4fc241a98dbf0f604e38 @hoan committed Sep 9, 2010
Showing with 20 additions and 3 deletions.
  1. +20 −3 phpcassa.php
View
@@ -156,6 +156,14 @@ public function get($key,
$slice_finish="",
$column_reversed=False,
$column_count=self::DEFAULT_COLUMN_LIMIT) {
+ // If we do get($key, $x) on a non-super column
+ // we should just return that attribute
+ if(!$this->is_super && $super_column) {
+ $result = $this->get($key, NULL, array($super_column));
+ return $result[$super_column];
+ }
+
+ // Otherwise do a normal get query
$column_parent = new cassandra_ColumnParent();
$column_parent->column_family = $this->column_family;
$column_parent->super_column = $this->unparse_column_name($super_column, true);
@@ -257,11 +265,20 @@ public function get_range_iterator($start_key="", $end_key="", $row_count=self::
return new CassandraIterator($this, $start_key, $end_key, $row_count, $slice_start, $slice_end);
}
- public function insert($key, $columns) {
+ public function insert($key, $columns=null) {
$timestamp = CassandraUtil::get_time();
- $cfmap = array();
- $cfmap[$key][$this->column_family] = $this->array_to_mutation($columns, $timestamp);
+ if(is_array($key)) {
+ // We ignore $columns and convert $key
+ // to an array map of all mutations
+ $cfmap = array();
+ foreach($key as $_key => $_columns) {
+ $cfmap[$_key][$this->column_family] = $this->array_to_mutation($_columns, $timestamp);
+ }
+ } else {
+ $cfmap = array();
+ $cfmap[$key][$this->column_family] = $this->array_to_mutation($columns, $timestamp);
+ }
$client = CassandraConn::get_client();
$resp = $client->batch_mutate($this->keyspace, $cfmap, $this->write_consistency_level);

0 comments on commit a9985d3

Please sign in to comment.