-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
63 lines (49 loc) · 2.06 KB
/
Copy pathindex.php
File metadata and controls
63 lines (49 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
//$em = new ORM\EntityManager();
require_once __DIR__ . "/vendor/autoload.php";
require_once __DIR__ . "/cli-config.php";
$isDevMode = true;
// Настройки будут браться из аннотаций, на мой взгляд, это удобнее
// Заметьте, что здесь я передаю путь до каталога, который будет содержать в себе классы сущностей, проецируемые на БД
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/models"), $isDevMode, null, null, false);
$parameters = array(
);//Здесь вам надо вытащить настройки подключения к БД для вашего проекта
//Здесь вам надо вытащить настройки подключения к БД для вашего проекта
$dbParams = array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => '',
'dbname' => 'newyear',
'charset' => 'UTF8',
);
$entityManager = EntityManager::create($dbParams, $config);
$em = $entityManager->getConnection();
//$em = $entityManager->getWrappedConnection();
//$q = $entityManager->createQuery("SELECT * FROM sys_urls");
$q = $em->prepare("SELECT * FROM sys_urls");
$q->execute();
$r = $q->fetchAll();
//$p = $q->bindParam();
//$r = $q->getArrayResult();
//$r = $q->getResult($q);
echo "<pre>";
//var_dump($r);
echo "</pre>";
//var_dump(realpath(__DIR__."/vendor/doctrine/orm/lib/Doctrine"));
//$param = array("parent" => "test9");
//$person = SysUrls::getRepository('PersonBlocked')->findBy($param);
//$testPost->setRowId(100);
$time1 = microtime();
for($i=0; $i<200; $i++) {
$testPost = new TestPost();
$testPost->setTestedit("zzzz" . rand(00, 99));
$testPost->setTesthid("uUuU" . rand(00, 99));
$testPost->setDatetime(new DateTime());
$entityManager->persist($testPost);
$entityManager->flush();
}
print_r(microtime() - $time1);
//var_dump($testPost);