doctrine

Doctrine cascade removing fails with OneToMany and OneToOne

梦想的初衷 提交于 2019-12-11 10:39:50
问题 I've been struggling for the past few days on a simple case of cascade removing using Doctrine. Doctrine and Symfony are up to date. I have two entities Serie and Asset that are linked to each other by two relationships OneToOne and OneToMany. The schema is exactly like this : A Serie has many Assets. (content). A Serie can have an Asset. (a preview, this field is nullable). However, no matter how I try to write and rewrite the annotations, I ALWAYS end up with this error: An exception

Relations while updating entity in Symfony2 - one-to-one and one-to-many doesn't work

只谈情不闲聊 提交于 2019-12-11 10:33:39
问题 I've a problem with updating an entity(it is inversed side) in form, while the entity is properly updated with all the data, the related to it other entities are not, i.e in database their column referencing the "main" entity remain null or the data remain untouched. Here is the code: class Offer { /** * @var ArrayCollection * * @ORM\OneToMany(targetEntity="DealOption", mappedBy="offer", cascade={"persist"}) */ private $dealOptions; /** * @var Event * * @ORM\OneToOne(targetEntity="Event",

symfony doctrine admin generator -> custom listing

强颜欢笑 提交于 2019-12-11 10:32:26
问题 I haven't found a way yet to customize what items are shown in the "list" view. To be a little bit more specific : by default all the records in a database table are selected and displayed, I want to be able to tweak a little the database select in order to select only a subset of items from the table. 回答1: config: list: table_method: getForAdminList Then, in a related model table class you can define your conditions to filter records: public function getForAdminList() { $q = $this-

Join queries in Doctrine on tables without specified relations

跟風遠走 提交于 2019-12-11 10:27:12
问题 I have two tables that do not have a relation defined with each other in the schema.yml. However, table 1 has a foreign key reference to the primary key of table 2. Clearly, I goofed up by not designing the database well, but now it's mitigation time. I must do a left join between the two tables coupled with a where clause that will retrieve the select rows I want. And to do this, I do: Doctrine_Query::create()->select('t.*, l.lid')->from('Taxonomy t')->leftJoin('t.Cid c') ->leftJoin('c

Symfony Doctrine One to Many does not insert foreign key

大憨熊 提交于 2019-12-11 10:21:38
问题 I am having annoying problems with persisting an entity with one or more OneToMany-Childs. I have a "Buchung" entity which can have multiple "Einsatztage" (could be translated to an event with many days) In the "Buchung entity I have /** * @param \Doctrine\Common\Collections\Collection $property * @ORM\OneToMany(targetEntity="Einsatztag", mappedBy="buchung", cascade={"all"}) */ private $einsatztage; $einsatztage is set to an ArrayCollection() in the __constructor(). Then there is the

symfony doctrine query result and execute function

℡╲_俬逩灬. 提交于 2019-12-11 10:16:34
问题 I have this doctrine query in symfony. It returns a lot of rows when i run mysql code generated by this dql query in phpBB but when i run it in symfony and access its results with this code: foreach ($this->courses as $course){ echo "<br>".$course->firstname;} it returns only one name. Also when i try to get $course->title , this error appears Unknown record property / related component "title" on "Students" Query: $q= Doctrine_Query::create() ->select('s.firstname, s.middlename, s.lastname,

FOSUserBundle: Get EntityManager instance overriding Form Handler

白昼怎懂夜的黑 提交于 2019-12-11 09:37:24
问题 I am starting with Symfony2 and I am trying to override FOS\UserBundle\Form\Handler\RegistrationFormHandler of FOSUserBundle. My code is: <?php namespace Testing\CoreBundle\Form\Handler; use FOS\UserBundle\Model\UserInterface; use FOS\UserBundle\Form\Handler\RegistrationFormHandler as BaseHandler; use Testing\CoreBundle\Entity\User as UserDetails; class RegistrationFormHandler extends BaseHandler { protected function onSuccess(UserInterface $user, $confirmation) { // I need an instance of

Symfony2 WebProfiler (500): Key “default” does not exist as the array is empty in @Doctrine/Collector/db.html.twig at line 209

爱⌒轻易说出口 提交于 2019-12-11 09:08:36
问题 Symfony2 WebProfiler (500): Key "default" does not exist as the array is empty in @Doctrine/Collector/db.html.twig at line 209 I have installed Sonata e-commerce 2.3 branch (fresh installation) on several machines (php 5.4, php 5.5), everything works fine, but and on each one i have the same error in profiler doctrine DB tab: Symfony2 WebProfiler (500): Key "default" does not exist as the array is empty in @Doctrine/Collector/db.html.twig at line 209 Profiler is working fine only after first

SQL Multiple sorting and grouping

↘锁芯ラ 提交于 2019-12-11 08:53:51
问题 EDIT: I'm using DQL I'm looking for help with an SQL query. My table has a list of movies, each with a title, seriesName and seriesNumber. Is it possible to order them so the Titles are listed A-Z, but when a series occurs, that series is grouped together, with the seriesName being placed alphabetically as if it were inthe movieTitle column, and the entries in a series ordered by seriesNumber. Bad explanation, but basically what I want is this: MovieTitle SeriesName SeriesNumber Blade Runner

Any hierarchical Data Support in Doctrine 2?

∥☆過路亽.° 提交于 2019-12-11 08:47:40
问题 in Doctrine 1, i see that it supports hierarchical data support? is there any in Doctrine 2? UPDATE 1 ok so i used Nested Set Extension for Doctrine 2. i have some questions 1. inserting a node // in the docs $child1 = new Category(); $child1->name = 'Child Category 1'; $child2 = new Category(); $child2->name = 'Child Category 2'; $category->addChild($child1); $category->addChild($child2); it seems like i must do something like $root = $nsm->createRoot($category); $root->addChild($child1);