Permalink
Browse files

use batch_mutate instead of batch_insert which is deprecated

  • Loading branch information...
1 parent 490098b commit 2396fb97dc647387cb947b9261e4132a21a47aa1 @hoan committed Jul 11, 2010
Showing with 15 additions and 3 deletions.
  1. +2 −1 README
  2. +13 −2 phpcassa.php
View
3 README
@@ -78,4 +78,5 @@ AUTHORS:
* Zach Buller (zachbuller@gmail.com)
* Timandes
* Todd Zusman
-
+* Yancho Georgiev (yancho@inspirestudio.net)
+* Pieter Maes (maescool@gmail.com)
View
@@ -216,10 +216,10 @@ public function insert($key, $columns) {
$timestamp = CassandraUtil::get_time();
$cfmap = array();
- $cfmap[$this->column_family] = $this->array_to_supercolumns_or_columns($columns, $timestamp);
+ $cfmap[$key][$this->column_family] = $this->array_to_mutation($columns, $timestamp);
$client = CassandraConn::get_client();
- $resp = $client->batch_insert($this->keyspace, $key, $cfmap, $this->write_consistency_level);
+ $resp = $client->batch_mutate($this->keyspace, $cfmap, $this->write_consistency_level);
return $resp;
}
@@ -318,6 +318,17 @@ public function columns_to_array($array_of_c) {
}
// Helpers for turning PHP arrays into Cassandra's thrift objects
+ public function array_to_mutation($array, $timestamp=null) {
+ $c_or_sc = $this->array_to_supercolumns_or_columns($array, $timestamp);
+ $ret = null;
+ foreach($c_or_sc as $row) {
+ $mutation = new cassandra_Mutation();
+ $mutation->column_or_supercolumn = $row;
+ $ret[] = $mutation;
+ }
+ return $ret;
+ }
+
public function array_to_supercolumns_or_columns($array, $timestamp=null) {
if(empty($timestamp)) $timestamp = CassandraUtil::get_time();

0 comments on commit 2396fb9

Please sign in to comment.