当前位置: 首页>>代码示例>>PHP>>正文


PHP UUID::v1方法代码示例

本文整理汇总了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]);
 }
开发者ID:jlaprise,项目名称:Pandra,代码行数:13,代码来源:PandraColumnFamilyTest.class.php

示例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)));
开发者ID:jlaprise,项目名称:Pandra,代码行数:31,代码来源:uuid_supercolumnfamily.class.php

示例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);
开发者ID:jlaprise,项目名称:Pandra,代码行数:31,代码来源:uuid_columnfamily.class.php


注:本文中的UUID::v1方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。