Share
Embed
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
PHPカンファレンス香川2025 の発表資料です。
- https://phpcon.kagawa.jp/2025/
- https://fortee.jp/phpconkagawa-2025
- https://fortee.jp/phpconkagawa-2025/proposal/56209220-8800-4584-a27b-08eb3d4cd2ef
Takashi Kanemoto
November 24, 2025
Transcript
169 slides
-
/ 147 30 Doctrine 方 2 025 / 11 /
2 4 PHP 香 2025 @ttskch  1 # #phpconkagawa -
/ 147 PHP 14 Symfony 13 phpcon 2025 行 長
Kannade  9 @ttskch -
/ 147 Symfony 用 PHP ORM Doctrine OSS Doctrine DBAL
Doctrine ORM Doctrine ⾒ Doctrine ORM Doctrine  12 -
/ 147 Doctrine ORM Doctrine DBAL 用 Doctrine ORM Doctrine
DBAL Doctrine  13 -
/ 147 Database Abstraction Layer DB DB DB DB DBAL
DB DB 一 Doctrine DBAL  14 -
/ 147 Object-Relational Mapper OOP 言 RDB DB PHP ORM
Eloquent ORM Laravel ORM Doctrine ORM  15 -
/ 147 ORM 2 Eloquent Active Record Doctrine Data Mapper
PoEAA Eloquent 比  17 https://www.martinfowler.com/eaaCatalog/activeRecord.html https://www.martinfowler.com/eaaCatalog/dataMapper.html -
/ 147 自 DB 👍 手 高 👎 DB DB
Active Record  18 -
/ 147 Active Record vs Data Mapper  22 Active
Record Data Mapper 手 長 高 比 高 -
/ 147 Doctrine DDD DDD ⾒ DB 一 1 PoEAA
Identity Map  28 https://martinfowler.com/eaaCatalog/identityMap.html -
/ 147 // Eloquent dump(spl_object_hash( Article::find(1), )); dump(spl_object_hash( Article::find(1), ));
dump(spl_object_hash( Article::find(1), )); // Doctrine dump(spl_object_hash( $articleRepository->find(1), )); dump(spl_object_hash( $articleRepository->find(1), )); dump(spl_object_hash( $articleRepository->find(1), ));  29 // "000000000000085b0000000000000000" // "000000000000085b0000000000000000" // "000000000000085b0000000000000000" // "00000000000012250000000000000000" // "00000000000011f90000000000000000" // "00000000000011f70000000000000000" -
/ 147  32 #[ORM\Entity] #[ORM\Table(name: 'article')] class Article {
#[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/ 147  33 #[ORM\Entity] #[ORM\Table(name: 'article')] class Article {
#[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } POPO Plain Old PHP Object DB -
/ 147 言 3 大 Doctrine DB Doctrine  48
Doctrine DB -
/ 147 Doctrine 3 Unit of Work 一 3 Doctrine
Doctrine 方  49 -
/ 147 Doctrine DB 一 PoEAA Unit of Work Unit
of Work  51 https://www.martinfowler.com/eaaCatalog/unitOfWork.html -
/ 147 DB  56 Unit of Work DB 口
Doctrine -
/ 147 DB  58 Unit of Work DB DB
Doctrine -
/ 147 DB  59 Unit of Work DB Unit
of Work Doctrine -
/ 147 Doctrine DB Unit of Work DB Doctrine DB
口 Doctrine DB  67 -
/ 147 DB  70 Unit of Work DB Doctrine
Unit of Work -
/ 147 DB  71 Unit of Work DB Doctrine
Unit of Work 自身 DB 行 -
/ 147 DB  72 Unit of Work DB Doctrine
Unit of Work 自身 -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } Article article -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } ORM Doctrine -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } $id ID Doctrine 自 id integer -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } $title title string 大長 255 文 -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } $content content text NULL -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } 方 -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } string integer text -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } string integer text 身 文 -
/ 147 integer string text Doctrine DBAL DB  93
DBAL MySQL PostgreSQL SQLite integer INT UNSIGNED INT INTEGER string VARCHAR VARCHAR VARCHAR text TEXT TEXT VARCHAR(MAX) https://www.doctrine-project.org/projects/doctrine-dbal/en/ 4 . 3 /reference/types.html#mapping-matrix -
/ 147 // ΤϯςΟςΟϚωʔδϟʔ͔Β // ArticleΤϯςΟςΟ༻ͷϦϙδτϦΛऔಘ $articleRepository = $entityManager->getRepository(Article::class); //
ϦϙδτϦܦ༝Ͱ // ID͕1ͷArticleΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1);  101 DB -
/ 147 // ΤϯςΟςΟϚωʔδϟʔ͔Β // ArticleΤϯςΟςΟ༻ͷϦϙδτϦΛऔಘ $articleRepository = $entityManager->getRepository(Article::class); //
ϦϙδτϦܦ༝Ͱ // ID͕1ͷArticleΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1);  102 DB Doctrine 色 💡 -
/ 147 // ΤϯςΟςΟϚωʔδϟʔ͔Β // ArticleΤϯςΟςΟ༻ͷϦϙδτϦΛऔಘ $articleRepository = $entityManager->getRepository(Article::class); //
ϦϙδτϦܦ༝Ͱ // ID͕1ͷArticleΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1);  103 $entityManager -
/ 147 // ΤϯςΟςΟϚωʔδϟʔ͔Β // ArticleΤϯςΟςΟ༻ͷϦϙδτϦΛऔಘ $articleRepository = $entityManager->getRepository(Article::class); //
ϦϙδτϦܦ༝Ͱ // ID͕1ͷArticleΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1);  104 $entityManager -
/ 147 #[Route('/article', name: 'article_')] class ArticleController extends AbstractController {
#[Route('/', name: 'index', methods: ['GET'])] public function index(EntityManagerInterface $entityManager): Response { $articleRepository = $entityManager->getRepository(Article::class); // ... } }  105 DI Symfony -
/ 147 #[Route('/article', name: 'article_')] class ArticleController extends AbstractController {
#[Route('/', name: 'index', methods: ['GET'])] public function index(EntityManagerInterface $entityManager): Response { $articleRepository = $entityManager->getRepository(Article::class); // ... } }  106 DI Symfony -
/ 147 #[Route('/article', name: 'article_')] class ArticleController extends AbstractController {
#[Route('/', name: 'index', methods: ['GET'])] public function index(EntityManagerInterface $entityManager): Response { $articleRepository = $entityManager->getRepository(Article::class); // ... } }  107 DI Symfony DI 🙏 -
/ 147 // ΤϯςΟςΟϚωʔδϟʔ͔Β // ArticleΤϯςΟςΟ༻ͷϦϙδτϦΛऔಘ $articleRepository = $entityManager->getRepository(Article::class); //
ϦϙδτϦܦ༝Ͱ // ID͕1ͷArticleΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1);  108 -
/ 147 // ΤϯςΟςΟϚωʔδϟʔ͔Β // ArticleΤϯςΟςΟ༻ͷϦϙδτϦΛऔಘ $articleRepository = $entityManager->getRepository(Article::class); //
ϦϙδτϦܦ༝Ͱ // ID͕1ͷArticleΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1);  109 $articleRepository-> fi nd(1) -
/ 147  110 fi nd() fi ndAll() fi ndBy()
⾒ fi ndOneBy() ⾒ 一 -
/ 147 // ID͕1ͷArticleΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1); // ͯ͢ͷArticleΤϯςΟςΟͷྻΛऔಘ $articles
= $articleRepository->findAll(); // ެ։ࡁΈͷArticleΤϯςΟςΟͷྻΛऔಘ $articles = $articleRepository->findBy(['published' => true]); // ެ։ࡁΈ͔ͭɺλΠτϧ͕ʮPHPΧϯϑΝϨϯε߳ʯͰ͋ΔArticleΤϯςΟςΟΛ1ͭऔಘ $article = $articleRepository->findOneBy([ 'published' => true, 'title' => 'PHPΧϯϑΝϨϯε߳', ]);  111 -
/ 147 // ID͕1ͷArticleΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1); // ͯ͢ͷArticleΤϯςΟςΟͷྻΛऔಘ $articles
= $articleRepository->findAll(); // ެ։ࡁΈͷArticleΤϯςΟςΟͷྻΛऔಘ $articles = $articleRepository->findBy(['published' => true]); // ެ։ࡁΈ͔ͭɺλΠτϧ͕ʮPHPΧϯϑΝϨϯε߳ʯͰ͋ΔArticleΤϯςΟςΟΛ1ͭऔಘ $article = $articleRepository->findOneBy([ 'published' => true, 'title' => 'PHPΧϯϑΝϨϯε߳', ]);  112 -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->...  113 -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->...  114 🤔 -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->...  116 -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  117 -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  118 生 立 Article a -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  119 WHERE :published -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  120 WHERE :query -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  121 ORDER BY -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  122 :published :query -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  123 立 -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  124 SQL 行 -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  125 -
/ 147 // ެ։ࡁΈ͔ͭɺ // λΠτϧʹʮPHPΧϯϑΝϨϯε߳ʯΛؚΉArticleΤϯςΟςΟͷྻΛɺ // IDͷ߱ॱͰऔಘ $articles =
$articleRepository->createQueryBuilder('a') ->where('a.published = :published') ->andWhere('a.title LIKE :query') ->orderBy('a.id', 'DESC') ->setParameter('published', true) ->setParameter('query', '%PHPΧϯϑΝϨϯε߳%') ->getQuery() ->getResult();  126 -
/ 147 // લఏͱͯ͠ϦϙδτϦ͔ΒΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1); // ී௨ʹΤϯςΟςΟͷ༰Λมߋ͢Ε //
Unit of Work͕ͦͷมߋ༰Λݕ͢Δ $article->title = '৽͍͠λΠτϧ'; // ͦͯ͠...  129 DB -
/ 147 // લఏͱͯ͠ϦϙδτϦ͔ΒΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1); // ී௨ʹΤϯςΟςΟͷ༰Λมߋ͢Ε //
Unit of Work͕ͦͷมߋ༰Λݕ͢Δ $article->title = '৽͍͠λΠτϧ'; // ͦͯ͠... // มߋ༰ͷDBͷөΛґཔ $entityManager->flush();  130 DB -
/ 147 // લఏͱͯ͠ϦϙδτϦ͔ΒΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1); // ී௨ʹΤϯςΟςΟͷ༰Λมߋ͢Ε //
Unit of Work͕ͦͷมߋ༰Λݕ͢Δ $article->title = '৽͍͠λΠτϧ'; // ͦͯ͠... // มߋ༰ͷDBͷөΛґཔ $entityManager->flush();  131 DB DB Unit of Work 💡 -
/ 147 // ΤϯςΟςΟΛ৽ن࡞ $article = new Article(); $article->title =
'λΠτϧ'; // ΤϯςΟςΟΛUnit of WorkʹՃ $entityManager->persist($article); // มߋ༰ͷDBͷөΛґཔ $entityManager->flush();  132 -
/ 147 // ΤϯςΟςΟΛ৽ن࡞ $article = new Article(); $article->title =
'λΠτϧ'; // ΤϯςΟςΟΛUnit of WorkʹՃ $entityManager->persist($article); // มߋ༰ͷDBͷөΛґཔ $entityManager->flush();  133 Unit of Work 行 🤦 -
/ 147 // ΤϯςΟςΟΛ৽ن࡞ʢ͜ͷ࣌Ͱ·ͩUnit of WorkͷཧԼʹͳ͍ʣ $article = new Article();
$article->title = 'λΠτϧ'; // ΤϯςΟςΟΛUnit of Workʹొ $entityManager->persist($article); // มߋ༰ʢ৽نՃΛؚΉʣͷDBͷөΛґཔ $entityManager->flush();  134 fl ush() -
/ 147 // લఏͱͯ͠ϦϙδτϦ͔ΒΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1); // ͦͯ͠... //
ΤϯςΟςΟΛআ͢ΔҙࢥΛUnit of Workʹ͑Δ $entityManager->remove($article); // มߋ༰ʢআΛؚΉʣͷDBͷөΛґཔ $entityManager->flush();  136 -
/ 147 // લఏͱͯ͠ϦϙδτϦ͔ΒΤϯςΟςΟΛऔಘ $article = $articleRepository->find(1); // ͦͯ͠... //
ΤϯςΟςΟΛআ͢ΔҙࢥΛUnit of Workʹ͑Δ $entityManager->remove($article); // มߋ༰ʢআΛؚΉʣͷDBͷөΛґཔ $entityManager->flush();  137 Unit of Work -
/ 147 // ΤϯςΟςΟΛ৽ن࡞ʢ͜ͷ࣌Ͱ·ͩUnit of WorkͷཧԼʹͳ͍ʣ $article = new Article();
$article->title = 'λΠτϧ'; // ΤϯςΟςΟΛআ͢ΔҙࢥΛUnit of Workʹ͑Δ $entityManager->remove($article); // มߋ༰ʢআΛؚΉʣͷDBͷөΛґཔ $entityManager->flush();  138 -
/ 147 // ΤϯςΟςΟΛ৽ن࡞ʢ͜ͷ࣌Ͱ·ͩUnit of WorkͷཧԼʹͳ͍ʣ $article = new Article();
$article->title = 'λΠτϧ'; // ΤϯςΟςΟΛআ͢ΔҙࢥΛUnit of Workʹ͑Δ $entityManager->remove($article); // มߋ༰ʢআΛؚΉʣͷDBͷөΛґཔ $entityManager->flush();  139 Unit of Work 示 行 ✋ -
/ 147 Doctrine Data Mapper 方 手 ・ 心 Doctrine
Doctrine ・ Unit of Work ・ 3 方・ 方 方 ・ ・ 方 30  143 -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] #[ORM\Table(name: 'article')] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(name: 'id', type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(name: 'title', type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(name: 'content', type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(type: Types::TEXT, nullable: true)] public ?string $content = null; } PHP PHP -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: Types::INTEGER)] public ?int $id = null; #[ORM\Column(type: Types::STRING, length: 255)] public ?string $title = null; #[ORM\Column(type: Types::TEXT, nullable: true)] public ?string $content = null; } PHP string DBAL text string 示 -
/xxx ຊจϨϕϧ1 ຊจϨϕϧ2 ຊจϨϕϧ3 ຊจϨϕϧ4 ຊจϨϕϧ5 use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping
as ORM; #[ORM\Entity] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] public ?int $id = null; #[ORM\Column(length: 255)] public ?string $title = null; #[ORM\Column(type: Types::TEXT, nullable: true)] public ?string $content = null; } -
/ 147 #[Route('/article', name: 'article_')] class ArticleController extends AbstractController {
#[Route('/', name: 'index', methods: ['GET'])] public function index(ArticleRepository $articleRepository): Response { // ... } }  164