doctrine

Symfony form creates new object and create first one-to-many object

扶醉桌前 提交于 2019-12-13 00:57:55
问题 I have an entity for support tickets: SupportTicket(). I also have an entry for replies to each ticket: SupportEntry(). I setup a one-to-many relationship between SupportTicket() and SupportEntry(). Now what I'm trying to do is build my form so that it creates the initial SupportTicket and then inserts the first SupportEntry, all in the same form. I've been messing around with my code for a while, only half-understanding what I'm doing, but this is where I'm at right now: // My controller,

Set the default timezone in symfony

不羁岁月 提交于 2019-12-12 22:16:04
问题 i want to know how can i set timezone for an entire project? i'm using symfony 1.4 with doctrine and i have a problem with datetime saving. whenever i save a record, it's time is not correct and i know that's because of timezone. i know i can use date_default_timezone_set() function to set default timezone, but i have to do it in every single action that i'm using date and it's not right. is there an easier way to do it? i think doctrine should have something to set it automatically but i don

Doctrine ORM CLI Tool Not working

不羁的心 提交于 2019-12-12 19:32:21
问题 I had doctrine version 2.3.2 , whose CLI tool was working perfectly. Now, just trying to update to ORM v2.4.4, which is having the following error just by running "./vendor/bin/doctrine" command: PHP Catchable fatal error: Argument 1 passed to Doctrine\ORM\Tools\Console\ConsoleRunner::run() must be an instance of Symfony\Component\Console\Helper\HelperSet, integer given, called in /vagrant/vendor/doctrine/orm/bin/doctrine.php on line 59 and defined in /vagrant/vendor/doctrine/orm/lib/Doctrine

Doctrine Searchable Behavior vs Zend Lucene in symfony

一个人想着一个人 提交于 2019-12-12 19:22:15
问题 I need to search for keywords in 2 table, simple thing I am undecided about using one or the other? any suggestion performance wise? Thanks! 回答1: As cuhuak mentioned, Lucene is a fulltext search. Since it is written in Java, you additionaly need a Java Server (Tomcat for example). If you don't want an additional server, the Zend Lucene implementation (as noted in the comments by Matt Gibson) may also be worth looking into. With an additional server and if you only have a small host, this MAY

Flushing in postPersist possible or not?

故事扮演 提交于 2019-12-12 19:04:37
问题 I have read the docs about lifecycle events, and several questions here on SO about changing or persisting new entities during lifecycle events. Calling EnitityManager::flush() seems to be a problem. Ok, but looking carefully at the docs, there is a code example where the field is changed in postPersist, but no flush is called. I checked that, and the suggested change is not written to the DB. Only the object being persisted does receive the change. <?php /** @Entity @HasLifecycleCallbacks */

Symfony3/Doctrine : ORDER BY CASE / Specific value first

你说的曾经没有我的故事 提交于 2019-12-12 17:26:33
问题 I'm searching a solution to order my query with query builder. I want to order my query by ASC but with a specific value at first place. I know how to do this in SQL with order by case ... but i found few solution that don't really work with doctrine. For example : i have a table with : A, B, D, C, F, E. I want to sort like this : F, A, B, C, D, E I found something like that in other topic but it doesn't work for me : $qb->addSelect("(CASE When c.type like 'foo%' Then 1 WHEN c.type like 'foo1

Symfony 2.8+, Doctrine Inheritance and Forms

谁都会走 提交于 2019-12-12 16:17:39
问题 Before i start, Note that I'm learning symfony so keep that in mind ! I just want to understand how it works. Here's what i am trying to achieve : I would like to make a working crud example of entities inheritance using doctrine. So this is how my example looks like : Abstract Parent class : character Child class 1 : Magician Child class 2 : Warrior Child class 3 : Archer So after reading some documentation i decided to use the STI (Single Table Inheritance) of Doctrine. Parent class : /** *

How to configure Doctrine Entity Annotation autoloading in User-defined symfony Bundle?

眉间皱痕 提交于 2019-12-12 14:35:50
问题 When I try to validate my symfony schema, I get the error: [Doctrine\Common\Annotations\AnnotationException] [Semantical Error] The annotation "@Doctrine\Orm\Mapping\Entity" in class C hill\EmailUser\Entity\EmailUser does not exist, or could not be auto-loaded I see that in this question: Trouble with importing annotations, it is said we need to change from Doctrine Simple Annotation Reader. Even though it seems strange to make bundle config in the autoloader, I tried doing that via app

How to get doctrine to generate sql with BIGINT type?

时光怂恿深爱的人放手 提交于 2019-12-12 13:58:11
问题 In my schema I have a number of field that need to be BIGINT. I use symfony's symfony doctrine:build-sql to generate my database. The fields always come out as type int. I have tried the following types in the schema: int {type: integer, notnull: true} {type: integer(5), notnull: true} {type: bigint, notnull: true} None of them seem to work (I always rebuild the model before building the SQL). What type should i put in the schema.yml? 回答1: With Symfony 2.x (e.g. Doctrine 2.4.1) and PHP

Symfony2/Doctrine2 model classes mappings for reusable bundle

我是研究僧i 提交于 2019-12-12 13:37:02
问题 I am currently trying to create a reusable bundle with Symfony2 using model classes but I am not able to register their mappings so Doctrine recognize them. I read that using compiler pass could be the solution so I followed the guide in the Symfony Cookbook (http://symfony.com/doc/current/cookbook/doctrine/mapping_model_classes.html) and I also looked at the source code in the FOSUserBundle for some inspiration. And here is what I've done so far : class GPGoodsBundle extends Bundle{ public