doctrine-orm

doctrine 2, how do get data from the inverse side (many to one)

左心房为你撑大大i 提交于 2020-01-16 09:04:32
问题 I have two entities, entry and comments. comments: /** * @Entity(repositoryClass="\Entities\Blog\CommentRepository") * @Table(name="blog_comment") * @HasLifecycleCallbacks */ class Comment extends \Entities\AbstractEntity { /** * @Id @Column(name="id", type="integer") * @GeneratedValue(strategy="AUTO") */ protected $id; /** * @ManyToOne(targetEntity="Entry", inversedBy="comments") * @JoinColumn(name="entry_id", referencedColumnName="id") */ protected $entry; /** @Column(name="approved", type=

Doctrine2 with Symfony2 not recognizing db charset and collation

浪子不回头ぞ 提交于 2020-01-15 14:13:57
问题 I am trying to get Doctrine2 to work properly with a mysql db in Symfony2 on a debian squeeze system. The charset and collation of the DB are set to utf8 and utf8_general_ci and the db is created manually by reading in an sql script. Now I enter some values for one of the tables with danish special chars like æøå and they simply wont display correctly. My parameters.yml has set encoding: utf8 and in my config.yml the doctrine configuration has: doctrine: dbal: driver: %database_driver% host:

Doctrine2 with Symfony2 not recognizing db charset and collation

爷,独闯天下 提交于 2020-01-15 14:11:46
问题 I am trying to get Doctrine2 to work properly with a mysql db in Symfony2 on a debian squeeze system. The charset and collation of the DB are set to utf8 and utf8_general_ci and the db is created manually by reading in an sql script. Now I enter some values for one of the tables with danish special chars like æøå and they simply wont display correctly. My parameters.yml has set encoding: utf8 and in my config.yml the doctrine configuration has: doctrine: dbal: driver: %database_driver% host:

Twig date filter not working with DateTime object

谁说我不能喝 提交于 2020-01-15 12:45:12
问题 I'm using CI2 with Doctrine2 and Twig for the template engine. I'm trying to display the date from an entity as a string, however it's not working for me. I'm sending an array of Entity objects to the template, iterating through them, and displaying their properties: {% for e in entities %} <span><label>username</label>{{e.getUserName}}</span> <span><label>email</label>{{e.getEmail}}</span> <span><label>date created</label>{{e.getCreatedAt | date('d.M.Y H:i:s')}}</span> {% endfor %} The

Twig date filter not working with DateTime object

天大地大妈咪最大 提交于 2020-01-15 12:45:06
问题 I'm using CI2 with Doctrine2 and Twig for the template engine. I'm trying to display the date from an entity as a string, however it's not working for me. I'm sending an array of Entity objects to the template, iterating through them, and displaying their properties: {% for e in entities %} <span><label>username</label>{{e.getUserName}}</span> <span><label>email</label>{{e.getEmail}}</span> <span><label>date created</label>{{e.getCreatedAt | date('d.M.Y H:i:s')}}</span> {% endfor %} The

Doctrine2 column type integer of length 255 doesn't apply to DB

被刻印的时光 ゝ 提交于 2020-01-15 12:36:05
问题 I'm using Doctrine 2 for my DB and I'm currently trying to set a length for one of my column that has an "integer" type but it just doesn't seem to be taken. /** @Column(type="integer", length=255) */ protected $number; When I check my database it still says "int(11)" instead of "int(255)". I haven't found anyone experiencing that problem on google or maybe my keywords ain't working so good. I've seen a few example of people using length=XXX and not complaining about it so I thought it would

Doctrine inheritance for entities common fields

[亡魂溺海] 提交于 2020-01-15 08:28:50
问题 I'm using Zend Framework 3 and Doctrine ORM for my web project. I have several modules in my application ( User , Stock , Sales ) and some entity models on each Module: User module entities: User , Account , etc.. Stock module entities: SKU , StockLevel , etc.. Sales module entities: Invoice , PaymentMethod , etc.. By default all entities has common fields, things like: creationDateTime : Date/time of creation creationUser : User who create the entity lastChangeDateTime : Date/time of last

Doctrine 2 conditional multiple row update with QueryBuilder

ⅰ亾dé卋堺 提交于 2020-01-15 08:01:08
问题 The question has some answers on SO, but non of them seems to help accomplish, actually, a simple task. I need to update multiple rows based on condition in one query, using Doctrine2 QueryBuilder. Most obvious way is supposed to be wrong: $userAgeList = [ 'user_name_a' => 30, 'user_name_b' => 40, 'user_name_c' => 50, ]; //Array of found `User` objects from database $usersList = $this->getUsersList(); foreach($usersList as $user) { $userName = $user->getName(); $user->setAge($userAgeList[

ZF2 + Doctrine2 - Fieldset in Fieldset of a Collection in Fieldset does not validate properly

有些话、适合烂在心里 提交于 2020-01-15 07:31:42
问题 I asked a similar question a while ago, which came down to the structuring of the Forms, Fieldsets and InputFilters. I've been thoroughly applying the principle of separation of concerns to split up Fieldsets from InputFilters as the modules they're created in will also be used in an API (Apigility based), so I would need only Entities and InputFilters. However, I now have a problem that when I have a Fieldset, used by a Fieldset, used in a Collection in a Fieldset, that the inner-most

Fatal error HelperSet not found when setting up Doctrine Console (with CodeIgniter)

混江龙づ霸主 提交于 2020-01-15 07:07:21
问题 I've got a problem setting up Doctrine with CodeIgniter. When running the following error is coming up: Fatal error: Class 'Symfony\Component\Console\Helper\HelperSet' not found in /Applications/MAMP/htdocs/CodeIgniter-2.2.1/application/doctrine.php on line 21 The folder structure looks like this /application/ /application/doctrine.php /application/libraries/ /application/libraries/Doctrine/ /application/libraries/Doctrine/Common /application/libraries/Doctrine/DBAL /application/libraries