thobbs / phpcassa

PHP client library for Apache Cassandra
thobbs.github.com/phpcassa
MIT License
248 stars 78 forks source link

Expose truncate() in sysmanager #27

Closed sebgiroux closed 13 years ago

sebgiroux commented 13 years ago

Shouldn't be too hard :)

Also not sure if its possible but add a drop_index function and maybe a get_index_list() or something like that to get all secondary index created for a CF if it's possible.

thobbs commented 13 years ago

Sounds reasonable to me.

sebgiroux commented 13 years ago

Here is the truncate code I added in sysmanager.php just before the drop_column_family function. Seems to works fine for me:) Feel free to use it if you're interested

    /*
     * Truncate a column family.
     *
     * Example usage:
     * <code>
     * $sys = SystemManager();
     * $sys->truncate_column_family("Keyspace1", "ColumnFamily1");
     * </code>
     *
     * @param string $keyspace the keyspace the CF is in
     * @param string $column_family the column family name
     */
    public function truncate_column_family($keyspace,$column_family) {
        $this->client->set_keyspace($keyspace);
        $this->client->truncate($column_family);
        $this->wait_for_agreement();
    }