doctrine

Entity of type 'AppBundle\Entity\User' for IDs id(155) was not found

ⅰ亾dé卋堺 提交于 2019-12-23 13:22:59
问题 When I iterate over users of one group (group#users and it's a ManyToOne relationship) to display the users emails, I get this error Entity of type 'AppBundle\Entity\User' for IDs id(155) was not found . However, when I display the user for which the exception is raised I see this: // In my controller dump($groups[0]->getUser()); // Output User {#761 ▼ +__isInitialized__: false #id: 155 #email: null #firstName: null #lastName: null #roles: null …2 } Besides, this user (whose id equals 155)

Doctrine2 Self Join, How to join on self without relationship column?

北城余情 提交于 2019-12-23 13:08:45
问题 Example mysql query: SELECT a1.* FROM agreement a1 LEFT JOIN agreement a2 on a1.agreementType = a2.agreementType and a2.id > a1.id WHERE a2.id is null The purpose of the query is to get the last agreement of the type returned. There are many types and I want only a listing of each latest agreement for each type. My example query above works as expected, but no go in DQL. How would I do this in DQL given I do not have a column that refers to itself? Note that "agreementType" is also a foreign

Symfony Serialize doctrine entity

霸气de小男生 提交于 2019-12-23 12:48:08
问题 I have a simple entity class: <?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; /** * @ORM\Entity(repositoryClass="CompanyUserRepository") * @ORM\Table(name="company_users") */ class CompanyUser { /** * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\Column(type="string", length=100) */ private $firstName; /** * @ORM\Column(type="string", length=100) */ private $lastName ;

Symfony Admin Generator Doctrine executeCreate

不问归期 提交于 2019-12-23 12:44:42
问题 Thanks for any help with this, I'm very new to the Symfony framework so just trying to get my head around it. I want to be able to intercept a submitted form from the admin area and modify the data. Here's what I've got so far (in basic form).. /apps/backend/modules/proposition/actions/action.class.php class propositionActions extends autoPropositionActions { public function executeCreate(sfWebRequest $request) { // modify the name $name = $request->getParameter('name'); $name = $name . ' is

NOT IN query with Doctrine QueryBuilder in a Many to Many relation

旧巷老猫 提交于 2019-12-23 12:37:52
问题 In my Symfony2 project, I have two entities "contact" and "settings", with a many to many relationship : /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Settings", cascade={"persist"}) * @ORM\JoinColumn(nullable=true) */ private $settings; Entity settings have a property "parametre", which is a simple string. Now I want to get all the contacts that DON'T have any settings which "parametre" is "THEMES". I can do that in SQL with a query like : SELECT DISTINCT(c.id) FROM contact c WHERE c

How to disable query logging in console while load Doctrine fixtures?

和自甴很熟 提交于 2019-12-23 12:07:55
问题 I have a fixtures that loads a huge amount of data and all the time I run into this error: Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 16777224 bytes) in /var/www/html/platform-cm/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php on line 65 [Symfony\Component\Debug\Exception\OutOfMemoryException] Error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 16777224 bytes) After research a bit I found this post where I read that

SQL / Doctrine : Left Join problem

限于喜欢 提交于 2019-12-23 11:52:35
问题 Currently this function works : it displays for a specific game, how many jobs there are. The problem : If there is no job, the game does not appear on the list. How to display the game even if there is no job attached ? Thanks public function getWithGames() { $q = $this->createQuery('c') ->leftJoin('c.stJob j') ->where('j.expires_at > ?', date('Y-m-d h:i:s', time())) ->addOrderBy('c.name'); $q->andWhere('j.is_activated = ?', 1); $q->andWhere('j.is_public = ?', 1); return $q->execute(); } 回答1

How to get Symfony2 connected with SQL Azure?

て烟熏妆下的殇ゞ 提交于 2019-12-23 10:23:06
问题 Is there somebody who was already successful with this topic? I already tried to write a custom Doctrine platform, but it isn't as easy as I thought. By the way this is the first question tagged with [sql-azure] [symfony-2.0] :/ 回答1: check https://github.com/beberlei/AzureDistributionBundle this should already work, at least for simple symfony2 applications. 来源: https://stackoverflow.com/questions/10140912/how-to-get-symfony2-connected-with-sql-azure

Doctrine ORM level difference between @UniqueConstraint and @Column(unique=true) options

陌路散爱 提交于 2019-12-23 10:09:50
问题 In database level, there is no difference when using one over another option for defining UNIQUENESS as shown below. Although @UniqueConstraint reads in its documentation " It only has meaning in the SchemaTool schema generation context ", is there a ORM level difference in between? I mean when we run queries, do things get handled differently? @UniqueConstraint @Column (unique=true) EXAMPLE - @UniqueConstraint CLASS /** * @ORM\Entity * @ORM\Table( * name="user", * uniqueConstraints={ * @ORM

doctrine join without relation [duplicate]

眉间皱痕 提交于 2019-12-23 09:56:36
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Is this possible to join tables in doctrine ORM without using relations? I have 2 classes Month and Vegetable. They don't have any relation together. I would like to play the SQL : SELECT * FROM month, vegetable In MySQL it works perfectly. I try it like that in Doctrine: $months = Doctrine_Query::create() ->select('m.*, v.*') ->from('month m, vegetable v') ->execute(); When I try it, I get : "vegetable" with an