本文整理汇总了PHP中Type::userType方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::userType方法的具体用法?PHP Type::userType怎么用?PHP Type::userType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type::userType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nestedCassandraTypes
/**
* Nested composite Cassandra types (list, map, set, tuple, and UDT) to be
* used by data providers
*/
public function nestedCassandraTypes()
{
$compositeCassandraTypes = $this->compositeCassandraTypes();
foreach ($compositeCassandraTypes as $nestedType) {
$type = Type::collection($nestedType[0]);
$nestedCassandraTypes[] = array($type, array($type->create($nestedType[1][0])));
}
foreach ($compositeCassandraTypes as $nestedType) {
$type = Type::set($nestedType[0]);
$nestedCassandraTypes[] = array($type, array($type->create($nestedType[1][0])));
}
foreach ($compositeCassandraTypes as $nestedType) {
$type = Type::map($nestedType[0], $nestedType[0]);
$nestedCassandraTypes[] = array($type, array($type->create($nestedType[1][0], $nestedType[1][1])));
}
foreach ($compositeCassandraTypes as $nestedType) {
$type = Type::tuple($nestedType[0], $nestedType[0]);
$nestedCassandraTypes[] = array($type, array($type->create($nestedType[1][0], $nestedType[1][1])));
}
foreach ($compositeCassandraTypes as $nestedType) {
$type = Type::userType("a", $nestedType[0], "b", $nestedType[0]);
$type = $type->withName(self::userTypeString($type));
$nestedCassandraTypes[] = array($type, array($type->create("a", $nestedType[1][0], "b", $nestedType[1][1])));
}
return $nestedCassandraTypes;
}
示例2: testNoPagingMemoryLeak
/**
* Paging advancement does not create memory leak
*
* This test will ensure that the driver does not create memory leaks
* associated advancing to the next page of results.
*
* @test
* @ticket PHP-101
*/
public function testNoPagingMemoryLeak()
{
// Create the user types and table for the test
$this->session->execute(new SimpleStatement("DROP TABLE {$this->tableNamePrefix}"));
$this->session->execute(new SimpleStatement("CREATE TYPE price_history (time timestamp, price float)"));
$priceHistory = Type::userType("time", Type::timestamp(), "price", Type::float());
$this->session->execute(new SimpleStatement("CREATE TYPE purchase_stats (day_of_week int, total_purchases int)"));
$purchaseStats = Type::userType("day_of_week", Type::int(), "total_purchases", Type::int());
$this->session->execute(new SimpleStatement("CREATE TABLE {$this->tableNamePrefix} (id uuid PRIMARY KEY,\n history frozen<price_history>, stats frozen<purchase_stats>,\n comments text)"));
// Populate the table with some random data
$totalInserts = 500;
$statement = $this->session->prepare("INSERT INTO {$this->tableNamePrefix}\n (id, history, stats, comments) VALUES (?, ?, ?, ?)");
foreach (range(1, $totalInserts) as $i) {
// Create the values for the insert
$history = $priceHistory->create("time", new Timestamp(mt_rand(1270094400000, 1459483200000)), "price", new Float(mt_rand(1, 1000) / 100));
$stats = $purchaseStats->create("day_of_week", mt_rand(0, 6), "total_purchases", mt_rand(0, 1000));
$values = array(new Uuid(), $history, $stats, $this->randomString());
$options = new ExecutionOptions(array("arguments" => $values));
$this->session->execute($statement, $options);
}
// Select all the rows in the table using paging
$statement = new SimpleStatement("SELECT * FROM {$this->tableNamePrefix}");
$options = new ExecutionOptions(array("page_size" => 2));
$rows = $this->session->execute($statement, $options);
// Validate paging and ensure all the rows were read
$count = $this->validatePageResults($rows);
$this->assertEquals($totalInserts, $count);
}
示例3: testPartial
/**
* Partial user type
*
* This test will ensure that partial user types return the correct value.
*
* @test
* @ticket PHP-58
*/
public function testPartial()
{
$userType = Type::userType("a", Type::int(), "b", Type::varchar(), "c", Type::bigint());
$userType = $userType->withName(self::userTypeString($userType));
$this->createUserType($userType);
$user = $userType->create();
$user->set("a", 99);
$this->createTableInsertAndVerifyValueByIndex($userType, $user);
$user = $userType->create();
$user->set("b", "abc");
$this->createTableInsertAndVerifyValueByIndex($userType, $user);
$user = $userType->create();
$user->set("c", new Bigint("999999999999"));
$this->createTableInsertAndVerifyValueByIndex($userType, $user);
}
示例4: notEqualTypes
public function notEqualTypes()
{
$setType = Type::set(Type::int());
return array(array(Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::varint())->create(), Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::bigint())->create()), array(Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::bigint())->create(), Type::userType('x', Type::int(), 'y', Type::varchar(), 'z', Type::bigint())->create()), array(Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::bigint())->create('a', 1, 'b', 'x', 'c', new Bigint(99)), Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::bigint())->create('a', 2, 'b', 'y', 'c', new Bigint(999))), array(Type::userType('a', $setType, 'b', Type::varchar())->create('a', $setType->create(1, 2, 3), 'b', 'x'), Type::userType('a', $setType, 'b', Type::varchar())->create('a', $setType->create(4, 5, 6), 'b', 'x')));
}