本文整理汇总了PHP中MongoClient::executeQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoClient::executeQuery方法的具体用法?PHP MongoClient::executeQuery怎么用?PHP MongoClient::executeQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoClient
的用法示例。
在下文中一共展示了MongoClient::executeQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @param array $data
* @return array
*/
public function run(array $data)
{
switch ($data['adapter']) {
case 'mysql':
$connection = DriverManager::getConnection($data['options']);
$connection->executeQuery('DROP TABLE IF EXISTS user_stream');
$adapter = new DoctrineEventStoreAdapter($connection, new FQCNMessageFactory(), new NoOpMessageConverter(), new JsonPayloadSerializer());
break;
case 'postgres':
$connection = DriverManager::getConnection($data['options']);
$connection->executeQuery('DROP TABLE IF EXISTS user_stream');
$adapter = new DoctrineEventStoreAdapter($connection, new FQCNMessageFactory(), new NoOpMessageConverter(), new JsonPayloadSerializer());
break;
case 'mongodb':
$connection = new \MongoClient($data['options']['server']);
$connection->selectDB('event_store_adapter_benchmarks')->selectCollection('user_stream')->drop();
$adapter = new MongoDbEventStoreAdapter(new FQCNMessageFactory(), new NoOpMessageConverter(), $connection, $data['options']['db_name']);
break;
default:
throw new \InvalidArgumentException('invalid adapter given');
break;
}
$eventStore = new EventStore($adapter, new ProophActionEventEmitter());
$result = [];
foreach ($data['batchSizes'] as $batchSize) {
for ($i = 0; $i < $this->repeats; $i++) {
$events = [];
$start = microtime(true);
for ($b = 1; $b <= $batchSize * 2; $b++) {
$v1 = $b;
$b++;
$v2 = $b;
$events[] = UserCreated::with(['name' => 'Max Mustermann ' . $i . '-' . $b, 'email' => 'contact' . $i . '-' . $b . '@prooph.de'], $v1);
$events[] = UsernameChanged::with(['name' => 'John Doe ' . $i . '-' . $b], $v2);
}
$eventStore->beginTransaction();
$eventStore->create(new Stream(new StreamName('user_stream'), new \ArrayIterator($events)));
$eventStore->commit();
$end = microtime(true);
if ($connection instanceof Connection) {
$connection->executeQuery('DROP TABLE IF EXISTS user_stream');
} else {
$connection->selectDB('event_store_adapter_benchmarks')->selectCollection('user_stream')->drop();
}
$diff = $end - $start;
$result[$data['adapter'] . ' with batch size ' . $batchSize] = $diff;
}
}
return $result;
}