From 2396fb97dc647387cb947b9261e4132a21a47aa1 Mon Sep 17 00:00:00 2001 From: Hoan Ton-That Date: Sun, 11 Jul 2010 05:28:59 -0700 Subject: [PATCH] use batch_mutate instead of batch_insert which is deprecated --- README | 3 ++- phpcassa.php | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README b/README index e3aab1cb..1e978b56 100644 --- a/README +++ b/README @@ -78,4 +78,5 @@ AUTHORS: * Zach Buller (zachbuller@gmail.com) * Timandes * Todd Zusman - +* Yancho Georgiev (yancho@inspirestudio.net) +* Pieter Maes (maescool@gmail.com) diff --git a/phpcassa.php b/phpcassa.php index a5433c01..30a96bd5 100644 --- a/phpcassa.php +++ b/phpcassa.php @@ -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();