Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added model support for removing supercolumns.

  • Loading branch information...
commit bc1eddf246bdc14164d8cd54204dedd47e3e9b5f 1 parent 872cf5e
@kallaspriit authored
Showing with 52 additions and 0 deletions.
  1. +52 −0 CassandraModel.php
View
52 CassandraModel.php
@@ -423,6 +423,32 @@ public static function remove(
}
/**
+ * 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.
*
* If the columns is left to null, the entire row is deleted.
@@ -449,6 +475,32 @@ public function delete(array $columns = null, $consistency = null) {
}
/**
+ * 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.
*
* The transformation is done in following steps:
Please sign in to comment.
Something went wrong with that request. Please try again.