本文整理汇总了PHP中UUID::v1方法的典型用法代码示例。如果您正苦于以下问题:PHP UUID::v1方法的具体用法?PHP UUID::v1怎么用?PHP UUID::v1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UUID
的用法示例。
在下文中一共展示了UUID::v1方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSaveLoadDeleteUUID
public function testSaveLoadDeleteUUID()
{
$cf = new PandraColumnFamily($this->_keyID, 'Keyspace1', 'StandardByUUID1', PandraColumnContainer::TYPE_UUID);
$column = $cf->addColumn(UUID::v1());
$uuidName = UUID::convert($column->getName(), UUID_FMT_STR);
$cValue = 'test value';
$column->setValue($cValue);
$this->assertTrue($cf->save());
unset($cf);
$newCF = new PandraColumnFamily($this->_keyID, 'Keyspace1', 'StandardByUUID1', PandraColumnContainer::TYPE_UUID);
$newCF->load();
$this->assertEquals($cValue, $newCF[$uuidName]);
}
示例2: BlogPost
$string = $chars[rand(0, $chars_length)];
// Generate random string
for ($i = 1; $i < $length; $i = strlen($string)) {
// Grab a random character from our list
$r = $chars[rand(0, $chars_length)];
// Make sure the same two characters don't appear next to each other
if ($r != $string[$i - 1]) {
$string .= $r;
}
}
// Return the string
return $string;
}
// generate 5 timestamped supercolumns
for ($i = 1; $i <= 5; $i++) {
$bp = new BlogPost(UUID::v1());
$bp->column_title = rand_str();
$bp->column_body = rand_str();
$scf->addSuper($bp);
}
echo 'Saving SuperColumnFamily...<br>';
print_r($scf->toJSON());
$scf->save();
// get slice of the 5 most recent entries (count = 5, reversed = true)
echo '<br><br>Loading via SuperColumnFamily container...<br>';
$scNew = new PandraSuperColumnFamily($keyID, $ks, $cfName, PandraColumnContainer::TYPE_UUID);
$scNew->limit(5)->load();
echo '<br>Loaded...<br>';
print_r($scNew->toJSON());
echo '<br><br>Loading SuperColumn Slice...<br>';
$result = PandraCore::getCFSlice($ks, $keyID, new cassandra_ColumnParent(array('column_family' => $cfName)), new PandraSlicePredicate(PandraSlicePredicate::TYPE_RANGE, array('start' => '', 'finish' => '', 'count' => 5, 'reversed' => true)));
示例3: PandraColumnFamily
/**
* Example TimeUUIDType ColumnFamily vs default Cassandra storage-conf.xml
*
* <ColumnFamily CompareWith="TimeUUIDType" Name="StandardByUUID1"/>
*
*/
require_once '../config.php';
PandraCore::connect('default', 'localhost');
// ---- TIMEUUID ColumnFamily Example
$ks = 'Keyspace1';
$cfName = 'StandardByUUID1';
$keyID = 'PandraTestUUID1';
$cf = new PandraColumnFamily($keyID, $ks, $cfName, PandraColumnFamily::TYPE_UUID);
// generate 5 timestamped columns
for ($i = 1; $i <= 5; $i++) {
$cf->addColumn(UUID::v1())->setValue($i);
}
echo 'Saving...<br>';
print_r($cf->toJSON());
$cf->save();
// get slice of the 5 most recent entries (count = 5, reversed = true)
echo '<br><br>Loading via CF container...<br>';
$cfNew = new PandraColumnFamily($keyID, $ks, $cfName, PandraColumnFamily::TYPE_UUID);
$cfNew->limit(5)->load();
echo '<br>Loaded...<br>';
print_r($cfNew->toJSON());
echo '<br><br>Loading Slice...<br>';
$result = PandraCore::getCFSlice($ks, $keyID, new cassandra_ColumnParent(array('column_family' => $cfName)), new PandraSlicePredicate(PandraSlicePredicate::TYPE_RANGE, array('start' => '', 'finish' => '', 'count' => 5, 'reversed' => true)));
var_dump($result);
$cfNew = new PandraColumnFamily($keyID, $ks, $cfName, PandraColumnFamily::TYPE_UUID);
$cfNew->populate($result);