Aerospike::removeBin - removes a bin from a record
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()).
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
- Aerospike::OPT_WRITE_TIMEOUT
- Aerospike::OPT_TTL
- Aerospike::OPT_POLICY_RETRY
- Aerospike::OPT_POLICY_KEY
- Aerospike::OPT_POLICY_GEN
- Aerospike::OPT_POLICY_COMMIT_LEVEL
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.
<?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.