Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Solutions avec Doctrine 2.0
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Anna Filina
May 05, 2011
Programming
39
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Solutions avec Doctrine 2.0
Anna Filina
May 05, 2011
More Decks by Anna Filina
See All by Anna Filina
Surviving a Symfony Upgrade
afilina
1
210
Upgrading Legacy to the Latest PHP Version
afilina
1
240
Better Code Design in PHP
afilina
0
330
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
230
Better Code Design in PHP
afilina
1
490
Better Code Design in PHP
afilina
0
660
Adding Tests to Untestable Legacy Code
afilina
0
450
Upgrading Legacy to the Latest PHP Version
afilina
0
460
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
360
Other Decks in Programming
See All in Programming
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
520
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
470
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
300
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
120
Intent as Code
shoppingjaws
6
1.1k
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5.3k
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
230
Simple Storage Service(S3) is not simple
iwatsukayura
0
120
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
380
iOSDCのペンライトを自動制御したい!
akkeylab
0
340
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
460
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
750
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
520
Become a Pro
speakerdeck
PRO
31
6.3k
The Limits of Empathy - UXLibs8
cassininazir
1
690
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Ethics towards AI in product and experience design
skipperchong
2
410
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
430
The Invisible Side of Design
smashingmag
301
52k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
How to make the Groovebox
asonas
2
2.5k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
550
Embracing the Ebb and Flow
colly
88
5.2k
Transcript
Solutions avec Doctrine 2.0 PHP Québec, 5 mai 2011
Anna Filina PHP Québec - groupe d’utilisateurs ConFoo - conférence
sans but lucratif FooLab - solution TI pour entreprises
Étendue ORM... De Kessé??? Setup Commandes de base Cas d’utilisation
en entreprise Gestion de rôles API
Pourquoi un ORM? Abstraction du SQL Standardiser Simplifier Réutilisation et
extensibilité
Setup
Entités class Invoice { public $id; public $items; public $total;
}
Entités: table /** * @Entity * @Table(name="invoice") */ class Invoice
{
Entités: colonne /** * @Id * @Column(type="integer") * @GeneratedValue */
public $id;
Bootstrap: driver $connectionOptions = array( 'driver' => 'pdo_sqlite', 'path' =>
'database.sqlite' );
Schéma >./doctrine orm:schema-tool:create
Commandes de base
Persistance $entityManager = EntityManager::create($conn, $config); $invoice = new Invoice(); $invoice->total
= 35.00; $entityManager->persist($invoice); $entityManager->flush();
Persistance avec relations $invoice = new Invoice(); $item = new
Item(); $item->name = 'Unicorn'; $invoice->items[] = $item; $entityManager->persist($invoice); $entityManager->flush();
Relation dans l’entité /** * @ManyToMany(targetEntity="Item", * cascade={"persist"}) */ public
$items;
Requêtes $query = $entityManager->createQuery( 'SELECT inv FROM Invoice inv'); $invoices
= $query->getResult();
Requêtes: left join $query = $entityManager->createQuery( 'SELECT inv, item FROM
Invoice inv LEFT JOIN inv.items item'); $invoices = $query->getResult();
Requêtes: left join array 'id' => 284 'total' => 0
'items' => array 0 => array 'id' => 279 'name' => 'Rainbow' 'price' => 10 'quantity' => 3 1 => array 'id' => 280 'name' => 'Unicorn' 'price' => 15 'quantity' => 2
Cas d’utilisation: Gestion de rôles
Rôles Admin: modifier tout Author: modifier projets de la compagnie
Reader: voir projets publiés seulement
Filtres Admin: * Author: WHERE project.organisation_id = ? Reader: WHERE
project.organisation_id = ? AND project.status = “Published”
Author class Author implements Role { public function filterQuery(&$q) {
$a = $q->getRootAlias(); $q->add('where', $a.'.organisation_id = :org_id'); $q->setParameter('org_id', $this->org_id); } }
Reader class Reader implements Role { public function filterQuery(&$q) {
$a = $q->getRootAlias(); $q->add('where', $a.'.organisation_id = :org_id'); $q->setParameter('org_id', $this->org_id); $q->add('where', $a.'.status = "Published"'); } }
Cas d’utilisation: API
API But: via AJAX, récupérer des données du serveur et
injecter dans une page Input: critères de recherche pour une liste Output: liste filtrée et paginée
Javascript $.ajax({ url: '/project.json', data: { page: 0, pageSize: 10
} success: function(json) { refreshHtmlTable(json); } });
PHP class API { public function process($entity, $filters) { $q
= $entity->getBaseQuery(); $q->setMaxResults($filters['pageSize']); $q->setFirstResult( $filters['pageSize'] * $filters['page']); $result = $q->getQuery() ->getResult(Query::HYDRATE_ARRAY); return json_encode($result); } }
Bonus Level!
Combinaisons class API { public function process($entity, $filters) { //
[...] $this->user->role->filterQuery($q); $q->getQuery()->useResultCache(true, 3600, 'uid'); // [...] } }
http://www.doctrine-project.org http://annafilina.com