Example #1
0
$key = $db->initKey("test", "vehicles", "M4G000");
$vehicle = array("make" => "Mazda", "model" => "CX-3", "year" => 2014, "color" => "red");
$options = array(Aerospike::OPT_POLICY_KEY => Aerospike::POLICY_KEY_SEND);
$status = $db->put($key, $vehicle, 0, $options);
if ($status === Aerospike::OK) {
    echo success();
} else {
    echo standard_fail($db);
}
if (isset($args['a']) || isset($args['annotate'])) {
    display_code(__FILE__, $start, __LINE__);
}
echo colorize("Instantiating an LList representing bin 'rental_history' of the given record ≻", 'black', true);
$start = __LINE__;
require_once realpath(__DIR__ . '/../../autoload.php');
$rental_history = new \Aerospike\LDT\LList($db, $key, 'rental_history');
if ($rental_history->errorno() === Aerospike::OK) {
    echo success();
} else {
    echo standard_fail($rental_history);
}
if (isset($args['a']) || isset($args['annotate'])) {
    display_code(__FILE__, $start, __LINE__);
}
echo colorize("Checking if the server actually has an LList at bin 'rental_history' of the record ≻", 'black', true);
$start = __LINE__;
if (!$rental_history->isLDT()) {
    echo fail("No LList exists yet at bin 'rental_history' of record {$key['key']}. Adding elements will initialize it.");
} else {
    echo success();
}
$key = $db->initKey("test", "shows", "futurama");
$futurama = array("channel" => array("Fox" => array(1999, 2000, 2001, 2002), "Comedy Central" => array(2008, 2009, 2010, 2011, 2012)), "creator" => array("Matt Groening", "David X. Cohen"), "show" => "Futurama");
$options = array(Aerospike::OPT_POLICY_KEY => Aerospike::POLICY_KEY_SEND);
$status = $db->put($key, $futurama, 0, $options);
if ($status === Aerospike::OK) {
    echo success();
} else {
    echo standard_fail($db);
}
if (isset($args['a']) || isset($args['annotate'])) {
    display_code(__FILE__, $start, __LINE__);
}
echo colorize("Instantiating an LList representing bin 'characters' of the given record ≻", 'black', true);
$start = __LINE__;
require_once realpath(__DIR__ . '/../../autoload.php');
$characters = new \Aerospike\LDT\LList($db, $key, 'characters');
if ($characters->errorno() === Aerospike::OK) {
    echo success();
} else {
    echo standard_fail($characters);
}
if (isset($args['a']) || isset($args['annotate'])) {
    display_code(__FILE__, $start, __LINE__);
}
echo colorize("Checking if the server actually has an LList at bin 'characters' of the record ≻", 'black', true);
$start = __LINE__;
if (!$characters->isLDT()) {
    echo fail("No LList exists yet at bin 'characters' of record {$key['key']}. Adding elements will initialize it.");
} else {
    echo success();
}
$key = $db->initKey("test", "numbers", "primes");
$primes = array("types" => 1);
$options = array(Aerospike::OPT_POLICY_KEY => Aerospike::POLICY_KEY_SEND);
$status = $db->put($key, $primes, 0, $options);
if ($status === Aerospike::OK) {
    echo success();
} else {
    echo standard_fail($db);
}
if (isset($args['a']) || isset($args['annotate'])) {
    display_code(__FILE__, $start, __LINE__);
}
echo colorize("Instantiating an LList representing centered triangular primes ≻", 'black', true);
$start = __LINE__;
require_once realpath(__DIR__ . '/../../autoload.php');
$tri_primes = new \Aerospike\LDT\LList($db, $key, 'triangular');
if ($tri_primes->errorno() === Aerospike::OK) {
    echo success();
} else {
    echo standard_fail($tri_primes);
}
if (isset($args['a']) || isset($args['annotate'])) {
    display_code(__FILE__, $start, __LINE__);
}
echo colorize("Checking if the server actually has an LList at bin 'triangular' of the record ≻", 'black', true);
$start = __LINE__;
if (!$tri_primes->isLDT()) {
    echo fail("No LList exists yet at bin 'triangular' of record {$key['key']}. Adding elements will initialize it.");
} else {
    echo success();
}