-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
89 lines (77 loc) · 2.44 KB
/
index.php
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* VIEW README FILE
* Replace these with the correct paths.
*/
$doctrineCommonPath = '/home/justin/fir.com/www/rialto/vendor/doctrine-common/lib';
$doctrineDbalPath = '/home/justin/fir.com/www/rialto/vendor/doctrine-dbal/lib';
$doctrineOrmPath = '/home/justin/fir.com/www/rialto/vendor/doctrine/lib';
require_once "{$doctrineCommonPath}/Doctrine/Common/ClassLoader.php";
use Doctrine\Common\ClassLoader;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Configuration;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ORM\Mapping\Driver\XmlDriver;
$paths = array(
'Doctrine\Common' => $doctrineCommonPath,
'Doctrine\DBAL' => $doctrineDbalPath,
'Doctrine\ORM' => $doctrineOrmPath,
'Test' => __DIR__,
'Proxies' => __DIR__,
);
foreach ( $paths as $namespace => $path ) {
$loader = new ClassLoader($namespace, $path);
$loader->register();
}
AnnotationRegistry::registerFile(
"{$doctrineOrmPath}/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"
);
$cache = new \Doctrine\Common\Cache\ArrayCache;
$config = new Configuration();
$config->setMetadataCacheImpl($cache);
$reader = new AnnotationReader();
/**
* VIEW README FILE
* comment/uncomment the below two lines to switch
* between XML and Annotation drivers
*/
$driver = new AnnotationDriver($reader, 'Test');
//$driver = new XmlDriver('Test');
$config->setMetadataDriverImpl($driver);
$config->setQueryCacheImpl($cache);
$config->setProxyDir('Proxies');
$config->setProxyNamespace('Proxies');
$config->setAutoGenerateProxyClasses(true);
$connectionOptions = array(
'driver' => 'pdo_sqlite',
'path' => 'database.sqlite'
);
$em = EntityManager::create($connectionOptions, $config);
$repo = $em->getRepository('Test\ProductDescription');
$descriptions = $repo->findAll();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
</head>
<body>
<table>
<tr>
<th>Product ID</th>
<th>Locale</th>
<th>Description</th>
</tr>
<?php foreach ($descriptions as $desc): ?>
<tr>
<td><?php echo $desc->getProductId(); ?></td>
<td><?php echo $desc->getLocale(); ?></td>
<td><?php echo $desc->getDescription(); ?></td>
</tr>
<?php endforeach; ?>
</table>
</body>
</html>