Permalink
Browse files

Added model support for removing supercolumns.

  • Loading branch information...
kallaspriit committed Apr 19, 2012
1 parent 872cf5e commit bc1eddf246bdc14164d8cd54204dedd47e3e9b5f
Showing with 52 additions and 0 deletions.
  1. +52 −0 CassandraModel.php
View
@@ -422,6 +422,32 @@ public static function remove(
return $model->delete($columns, $consistency);
}
+ /**
+ * Removes a supercolumn entry or some columns of it.
+ *
+ * If the columns is left to null, the entire row is deleted.
+ *
+ * If you already have an instance of the model, use deleteSuper().
+ *
+ * @param string $key Row key to delete
+ * @param string $supercolumn Supercolumn name
+ * @param array $columns Optional columns to delete
+ * @param integer $consistency Option override of default consistency level
+ * @param Cassandra $connection If not set, the default connection is used
+ * @return boolean Was removing the entry successful
+ */
+ public static function removeSuper(
+ $key,
+ $supercolumn,
+ array $columns = null,
+ $consistency = null,
+ Cassandra $connection = null
+ ) {
+ $model = self::getInstance($key, $connection);
+
+ return $model->deleteSuper($supercolumn, $columns, $consistency);
+ }
+
/**
* Removes an entry or some columns of it.
*
@@ -448,6 +474,32 @@ public function delete(array $columns = null, $consistency = null) {
return true;
}
+ /**
+ * Removes an supercolumn entry or some columns of it.
+ *
+ * If the columns is left to null, the entire row is deleted.
+ *
+ * Uses the currently set row key, you can change it with key() method.
+ *
+ * You can remove a row by calling removeSuper() statically.
+ *
+ * @param array $columns Optional columns to delete
+ * @param integer $consistency Option override of default consistency level
+ * @return boolean Was removing the entry successful
+ */
+ public function deleteSuper($supercolumn, array $columns = null, $consistency = null) {
+ $columnFamily = self::getColumnFamilyName();
+
+ $this->_connection->cf($columnFamily)->remove(
+ $this->_key,
+ $columns,
+ $supercolumn,
+ $consistency
+ );
+
+ return true;
+ }
+
/**
* Returns the column family name that corresponds to given model class.
*

0 comments on commit bc1eddf

Please sign in to comment.