{"id":7,"date":"2017-06-06T13:50:04","date_gmt":"2017-06-06T11:50:04","guid":{"rendered":"http:\/\/numa-bord.com\/miniblog\/?p=7"},"modified":"2017-07-04T15:44:33","modified_gmt":"2017-07-04T13:44:33","slug":"symfony-relations-entre-entites","status":"publish","type":"post","link":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/","title":{"rendered":"Symfony : Relations entre entit\u00e9s"},"content":{"rendered":"<p>Exemple de relation entre entit\u00e9s Doctrine dans Symfony<\/p>\n<p><strong>Relation \u00ab\u00a0unique\u00a0\u00bb (ManyToOne) entre \u00ab\u00a0Child\u00a0\u00bb et \u00ab\u00a0School\u00a0\u00bb <\/strong><\/p>\n<div class=\"codecolorer-container php default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"php codecolorer\">&nbsp; &nbsp; <span class=\"co1\">\/\/cot\u00e9 Child<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"co4\">\/**<br \/>\n&nbsp; &nbsp; &nbsp;* @ORM\\ManyToOne(targetEntity=&quot;AppBundle\\Entity\\School&quot;, inversedBy=&quot;children&quot;)<br \/>\n&nbsp; &nbsp; &nbsp;* @ORM\\JoinColumn(name=&quot;school_id&quot;, referencedColumnName=&quot;id&quot;, nullable=false)<br \/>\n&nbsp; &nbsp; &nbsp;*\/<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">protected<\/span> <span class=\"re0\">$school<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<div class=\"codecolorer-container php default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"php codecolorer\">&nbsp; &nbsp; <span class=\"co1\">\/\/cot\u00e9 School<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"co4\">\/**<br \/>\n&nbsp; &nbsp; &nbsp;* @ORM\\OneToMany(targetEntity=&quot;AppBundle\\Entity\\Child&quot;, mappedBy=&quot;school&quot;)<br \/>\n&nbsp; &nbsp; &nbsp;*\/<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">protected<\/span> <span class=\"re0\">$children<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p><strong>Relation \u00ab\u00a0multiple\u00a0\u00bb (ManyToMany) entre \u00ab\u00a0Child\u00a0\u00bb et \u00ab\u00a0Member\u00a0\u00bb <\/strong><\/p>\n<div class=\"codecolorer-container php default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"php codecolorer\">&nbsp; &nbsp; <span class=\"co1\">\/\/cot\u00e9 Child<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"co4\">\/**<br \/>\n&nbsp; &nbsp; &nbsp;* @ORM\\ManyToMany(targetEntity=&quot;AppBundle\\Entity\\Member&quot;, inversedBy=&quot;children&quot;)<br \/>\n&nbsp; &nbsp; &nbsp;*\/<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">protected<\/span> <span class=\"re0\">$members<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<div class=\"codecolorer-container php default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"php codecolorer\">&nbsp; &nbsp; <span class=\"co1\">\/\/cot\u00e9 Member<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"co4\">\/**<br \/>\n&nbsp; &nbsp; &nbsp;* @ORM\\ManyToMany(targetEntity=&quot;AppBundle\\Entity\\Child&quot;, mappedBy=&quot;members&quot;)<br \/>\n&nbsp; &nbsp; &nbsp;*\/<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">protected<\/span> <span class=\"re0\">$children<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Exemple de relation entre entit\u00e9s Doctrine dans Symfony Relation \u00ab\u00a0unique\u00a0\u00bb (ManyToOne) entre \u00ab\u00a0Child\u00a0\u00bb et \u00ab\u00a0School\u00a0\u00bb &nbsp; &nbsp; \/\/cot\u00e9 Child &nbsp; &nbsp; \/** &nbsp; &nbsp; &nbsp;* @ORM\\ManyToOne(targetEntity=&quot;AppBundle\\Entity\\School&quot;, inversedBy=&quot;children&quot;) &nbsp; &nbsp; &nbsp;* @ORM\\JoinColumn(name=&quot;school_id&quot;, referencedColumnName=&quot;id&quot;, nullable=false) &nbsp; &nbsp; &nbsp;*\/ &nbsp; &nbsp; protected $school; &nbsp; &nbsp; \/\/cot\u00e9 School &nbsp; &nbsp; \/** &nbsp; &nbsp; &nbsp;* @ORM\\OneToMany(targetEntity=&quot;AppBundle\\Entity\\Child&quot;, mappedBy=&quot;school&quot;) &nbsp; &nbsp; &nbsp;*\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,4,3],"tags":[],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-developpement","category-doctrine","category-symfony"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Symfony : Relations entre entit\u00e9s - Pense b\u00eate d&#039;un d\u00e9veloppeur web<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Symfony : Relations entre entit\u00e9s - Pense b\u00eate d&#039;un d\u00e9veloppeur web\" \/>\n<meta property=\"og:description\" content=\"Exemple de relation entre entit\u00e9s Doctrine dans Symfony Relation \u00ab\u00a0unique\u00a0\u00bb (ManyToOne) entre \u00ab\u00a0Child\u00a0\u00bb et \u00ab\u00a0School\u00a0\u00bb &nbsp; &nbsp; \/\/cot\u00e9 Child &nbsp; &nbsp; \/** &nbsp; &nbsp; &nbsp;* @ORMManyToOne(targetEntity=&quot;AppBundleEntitySchool&quot;, inversedBy=&quot;children&quot;) &nbsp; &nbsp; &nbsp;* @ORMJoinColumn(name=&quot;school_id&quot;, referencedColumnName=&quot;id&quot;, nullable=false) &nbsp; &nbsp; &nbsp;*\/ &nbsp; &nbsp; protected $school; &nbsp; &nbsp; \/\/cot\u00e9 School &nbsp; &nbsp; \/** &nbsp; &nbsp; &nbsp;* @ORMOneToMany(targetEntity=&quot;AppBundleEntityChild&quot;, mappedBy=&quot;school&quot;) &nbsp; &nbsp; &nbsp;*\/ [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/\" \/>\n<meta property=\"og:site_name\" content=\"Pense b\u00eate d&#039;un d\u00e9veloppeur web\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-06T11:50:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-07-04T13:44:33+00:00\" \/>\n<meta name=\"author\" content=\"Numa\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"Numa\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/\"},\"author\":{\"name\":\"Numa\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e\"},\"headline\":\"Symfony : Relations entre entit\u00e9s\",\"datePublished\":\"2017-06-06T11:50:04+00:00\",\"dateModified\":\"2017-07-04T13:44:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/\"},\"wordCount\":101,\"commentCount\":0,\"articleSection\":[\"D\u00e9veloppement\",\"Doctrine\",\"Symfony\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/\",\"url\":\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/\",\"name\":\"Symfony : Relations entre entit\u00e9s - Pense b\u00eate d&#039;un d\u00e9veloppeur web\",\"isPartOf\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#website\"},\"datePublished\":\"2017-06-06T11:50:04+00:00\",\"dateModified\":\"2017-07-04T13:44:33+00:00\",\"author\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e\"},\"breadcrumb\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/numa-bord.com\/miniblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Symfony : Relations entre entit\u00e9s\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#website\",\"url\":\"https:\/\/numa-bord.com\/miniblog\/\",\"name\":\"Pense b\u00eate d&#039;un d\u00e9veloppeur web\",\"description\":\"(php, javascript, Symfony, Wordpress....)\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/numa-bord.com\/miniblog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e\",\"name\":\"Numa\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g\",\"caption\":\"Numa\"},\"url\":\"https:\/\/numa-bord.com\/miniblog\/author\/negonner\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Symfony : Relations entre entit\u00e9s - Pense b\u00eate d&#039;un d\u00e9veloppeur web","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/","og_locale":"fr_FR","og_type":"article","og_title":"Symfony : Relations entre entit\u00e9s - Pense b\u00eate d&#039;un d\u00e9veloppeur web","og_description":"Exemple de relation entre entit\u00e9s Doctrine dans Symfony Relation \u00ab\u00a0unique\u00a0\u00bb (ManyToOne) entre \u00ab\u00a0Child\u00a0\u00bb et \u00ab\u00a0School\u00a0\u00bb &nbsp; &nbsp; \/\/cot\u00e9 Child &nbsp; &nbsp; \/** &nbsp; &nbsp; &nbsp;* @ORMManyToOne(targetEntity=&quot;AppBundleEntitySchool&quot;, inversedBy=&quot;children&quot;) &nbsp; &nbsp; &nbsp;* @ORMJoinColumn(name=&quot;school_id&quot;, referencedColumnName=&quot;id&quot;, nullable=false) &nbsp; &nbsp; &nbsp;*\/ &nbsp; &nbsp; protected $school; &nbsp; &nbsp; \/\/cot\u00e9 School &nbsp; &nbsp; \/** &nbsp; &nbsp; &nbsp;* @ORMOneToMany(targetEntity=&quot;AppBundleEntityChild&quot;, mappedBy=&quot;school&quot;) &nbsp; &nbsp; &nbsp;*\/ [&hellip;]","og_url":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/","og_site_name":"Pense b\u00eate d&#039;un d\u00e9veloppeur web","article_published_time":"2017-06-06T11:50:04+00:00","article_modified_time":"2017-07-04T13:44:33+00:00","author":"Numa","twitter_card":"summary_large_image","twitter_misc":{"\u00c9crit par":"Numa"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/#article","isPartOf":{"@id":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/"},"author":{"name":"Numa","@id":"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e"},"headline":"Symfony : Relations entre entit\u00e9s","datePublished":"2017-06-06T11:50:04+00:00","dateModified":"2017-07-04T13:44:33+00:00","mainEntityOfPage":{"@id":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/"},"wordCount":101,"commentCount":0,"articleSection":["D\u00e9veloppement","Doctrine","Symfony"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/","url":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/","name":"Symfony : Relations entre entit\u00e9s - Pense b\u00eate d&#039;un d\u00e9veloppeur web","isPartOf":{"@id":"https:\/\/numa-bord.com\/miniblog\/#website"},"datePublished":"2017-06-06T11:50:04+00:00","dateModified":"2017-07-04T13:44:33+00:00","author":{"@id":"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e"},"breadcrumb":{"@id":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/numa-bord.com\/miniblog\/symfony-relations-entre-entites\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/numa-bord.com\/miniblog\/"},{"@type":"ListItem","position":2,"name":"Symfony : Relations entre entit\u00e9s"}]},{"@type":"WebSite","@id":"https:\/\/numa-bord.com\/miniblog\/#website","url":"https:\/\/numa-bord.com\/miniblog\/","name":"Pense b\u00eate d&#039;un d\u00e9veloppeur web","description":"(php, javascript, Symfony, Wordpress....)","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/numa-bord.com\/miniblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Person","@id":"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e","name":"Numa","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g","caption":"Numa"},"url":"https:\/\/numa-bord.com\/miniblog\/author\/negonner\/"}]}},"_links":{"self":[{"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":6,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":15,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/posts\/7\/revisions\/15"}],"wp:attachment":[{"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}