Error Handling - aerospike-community/aerospike-client-php GitHub Wiki

Use the Aerospike PHP client to manage errors.

Use the Aerospike PHP client to manage errors.

The Aerospike PHP client passes the status code that returns from the underlying C client. All non-zero status codes (!== Aerospike::OK) are errors.

Status codes are constants of the Aerospike class.

$status = $db->get($key, $record);
if ($status == Aerospike::OK) {
    var_dump($record);
} elseif ($status == Aerospike::ERR_RECORD_NOT_FOUND) {
    echo "A record with this key does not exist in the database\n";
}

Determining Operation Status

Use these calls to determine the operation status of the most-recent client operation:

  • error()
  • errorno()
$db = new Aerospike($config);
if (!$db->isConnected()) {
   echo "Failed to connect[{$db->errorno()}]: {$db->error()}\n";
   exit(1);
}