Aerospike::append - appends a string to the string value in a bin
public int Aerospike::append ( array $key, string $bin, string $value [, array $options ] )
Aerospike::append() will append a string to the string value in bin. Like other bin operations, append() only works on existing records (i.e. ones that were previously created with a put()).
key the key under which the record can be found. An array with keys ['ns','set','key'] or ['ns','set','digest'].
bin the name of the bin in which we have a numeric value.
value the string to append to the string value in the bin.
options including
- Aerospike::OPT_WRITE_TIMEOUT
- Aerospike::OPT_TTL
- Aerospike::OPT_POLICY_RETRY
- Aerospike::OPT_POLICY_KEY
- Aerospike::OPT_POLICY_GEN
- Aerospike::OPT_POLICY_REPLICA
- Aerospike::OPT_POLICY_CONSISTENCY
- 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 = array("hosts"=>array(array("addr"=>"localhost", "port"=>3000)));
$db = new Aerospike($config);
if (!$db->isConnected()) {
echo "Aerospike failed to connect[{$db->errorno()}]: {$db->error()}\n";
exit(1);
}
$key = $db->initKey("test", "users", 1234);
$options = array(Aerospike::OPT_TTL => 3600);
$status = $db->append($key, 'name', ' Ph.D.', $options);
if ($status == Aerospike::OK) {
echo "Added the Ph.D. suffix to the user.\n";
} else {
echo "[{$db->errorno()}] ".$db->error();
}
?>We expect to see:
Added the Ph.D. suffix to the user.