Skip to content

Latest commit

 

History

History
73 lines (52 loc) · 2.22 KB

aerospike_removebin.md

File metadata and controls

73 lines (52 loc) · 2.22 KB

Aerospike::removeBin

Aerospike::removeBin - removes a bin from a record

Description

public int Aerospike::removeBin ( array $key, array $bins [, array $options ] )

Aerospike::removeBin() will remove the specified bins from the record* with a given key. Like other bin operations, removeBin() only works on existing records (i.e. ones that were previously created with a put()).

Parameters

key the key for the record. An array with keys ['ns','set','key'] or ['ns','set','digest'].

bins the name of the bins to be removed from the record.

options including

Return Values

Returns an integer status code. Compare to the Aerospike class status constants. When non-zero the Aerospike::error() and Aerospike::errorno() methods can be used.

Examples

<?php

$config = ["hosts" => [["addr"=>"localhost", "port"=>3000]], "shm"=>[]];
$client = new Aerospike($config, true);
if (!$client->isConnected()) {
   echo "Aerospike failed to connect[{$client->errorno()}]: {$client->error()}\n";
   exit(1);
}

$key = ["ns" => "test", "set" => "users", "key" => 1234];
$options = array(Aerospike::OPT_TTL => 3600);
$status = $client->removeBin($key, ["age"], $options);
if ($status == Aerospike::OK) {
    echo "Removed bin 'age' from the record.\n";
} elseif ($status == Aerospike::ERR_RECORD_NOT_FOUND) {
    echo "The database has no record with the given key.\n";
} else {
    echo "[{$client->errorno()}] ".$client->error();
}

?>

We expect to see:

Removed bin 'age' from the record.

or

The database has no record with the given key.