doctrine-orm

Automatic values for updated_at, created_at in Doctrine

匆匆过客 提交于 2020-06-09 08:09:45
问题 I want to make fields updated_at and created_at in my Doctrine entities to update automatically. In Ruby on Rails models there are 2 fields: updated_at and created_at . Description can be found here: http://guides.rubyonrails.org/migrations.html#migration-overview: The timestamps macro adds two columns, created_at and updated_at. These special columns are automatically managed by Active Record if they exist. Can I enable similar functionality in Doctrine 2? 回答1: You can call $this-

Automatic values for updated_at, created_at in Doctrine

偶尔善良 提交于 2020-06-09 08:09:25
问题 I want to make fields updated_at and created_at in my Doctrine entities to update automatically. In Ruby on Rails models there are 2 fields: updated_at and created_at . Description can be found here: http://guides.rubyonrails.org/migrations.html#migration-overview: The timestamps macro adds two columns, created_at and updated_at. These special columns are automatically managed by Active Record if they exist. Can I enable similar functionality in Doctrine 2? 回答1: You can call $this-

Get maximum id inside Doctrine entity

痞子三分冷 提交于 2020-05-17 07:15:06
问题 I need to get maximum ID of a table inside of symfony 2.7 entity. But instead of having the id I'm getting this issue. Notice: Undefined property: AppBundle\Entity\BlogPost::$container This is my BlogPost entity, <?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\File\UploadedFile; /** * BlogPost * * @ORM\Table() * @ORM\Entity */ class BlogPost { const SERVER_PATH_TO_IMAGE_FOLDER = '/uploads'; /** * @var integer * * @ORM\Column(name="id",

Doctorine check if record exists in database [duplicate]

吃可爱长大的小学妹 提交于 2020-05-17 03:43:02
问题 This question already has an answer here : Doctrine - check if record exists based on field (1 answer) Closed 4 years ago . I would like to check if a record exist in the database. The only thing it needs to return is true or false. I'm now using the following query to get the record. Is the an other command as getResult() to check if the record exists? return $this->createQueryBuilder('u') ->andWhere('u.email = :email AND u.id != :id') ->setParameter('email', $email) ->setParameter('id',

Doctorine check if record exists in database [duplicate]

╄→尐↘猪︶ㄣ 提交于 2020-05-17 03:43:00
问题 This question already has an answer here : Doctrine - check if record exists based on field (1 answer) Closed 4 years ago . I would like to check if a record exist in the database. The only thing it needs to return is true or false. I'm now using the following query to get the record. Is the an other command as getResult() to check if the record exists? return $this->createQueryBuilder('u') ->andWhere('u.email = :email AND u.id != :id') ->setParameter('email', $email) ->setParameter('id',

Doctorine check if record exists in database [duplicate]

最后都变了- 提交于 2020-05-17 03:42:14
问题 This question already has an answer here : Doctrine - check if record exists based on field (1 answer) Closed 4 years ago . I would like to check if a record exist in the database. The only thing it needs to return is true or false. I'm now using the following query to get the record. Is the an other command as getResult() to check if the record exists? return $this->createQueryBuilder('u') ->andWhere('u.email = :email AND u.id != :id') ->setParameter('email', $email) ->setParameter('id',

Doctrine 2.5: Unrecognized field (but only in Symfony's prod mode)

拥有回忆 提交于 2020-05-15 07:19:31
问题 So I seem to be plagued by issues that only affect production mode in Symfony and not developer mode. This time, I have a ManyToOne association and I'm trying to fetch only the entities which do not have an association (i.e. they have a NULL value in the database). This works exactly as I'd expect in dev move, but in prod mode, Doctrine throws an "unrecognized field" exception... for a field which absolutely does exist. Here's the relevant part of the entity in question (Page.php): /** * @ORM

Symfony Doctrine ORM CLI Font/Colors not working?

孤者浪人 提交于 2020-05-15 02:16:46
问题 I have been looking online to see how to fix this, and have been unsuccessful. I've actually had this issue for over a year now and have simply just ignored it. Now that I'm doing more doctrine ORM stuff in my Symfony 4.1 project, I would like to know if anyone knows how to fix the font/colors on my Windows 10 machine? Command Line tools: * Powershell - Doesn't show the colors correctly * Command Prompt - Doesn't show the colors correctly * Git CMD - Doesn't show the colors correctly This is

What is the difference between WITH and ON in Doctrine Join condition type?

*爱你&永不变心* 提交于 2020-04-10 07:41:27
问题 I'm searching for a better explanation about the difference between WITH and ON condition type for the doctrine clausure. I'm finding the documentation about this very poor and I'm still in doubt. 回答1: In my opinion it's kind of a left over from doctrine 1. Back then ON was used to redefine the join conditions of relations, whereas WITH was used to add more join conditions to the default one. Now in doctrine 2 I have never seen a situation where ON can be used. In fact using ON always ends up

Symfony2 invalid form still saves entity on flush

让人想犯罪 __ 提交于 2020-03-18 09:56:14
问题 I currently have a form and on save I always make an API call to validate the form information against an external source (eg: is the company a VAT paying company etc.). I also want to store in the database the response I get from the external API, for which I have a post submit subscriber on the form. In the subscriber, I call the API and set errors on the form where values do not match. That is where I call a service to handle all the business logic and somewhere in there I have $em-