doctrine

Doctrine many-to-one returns only the identifier

六眼飞鱼酱① 提交于 2019-12-24 03:18:23
问题 I have a unidirectional many-to-one relation between capacity and product. When i want to get a property of an object in the array collection i get "null". The mapping: ''' http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="\Capacity" table="capacity"> <id name="id" type="integer"> <generator strategy="AUTO" /> </id> <!-- Relation: product --> <many-to-one field="product" target-entity="IDT\Component\Paylogic\Model\Product"> <join-column name="product_id" referenced

Apigility - How to use Doctrine ORM Module from ZF2 command line

馋奶兔 提交于 2019-12-24 01:44:19
问题 Hi i'm new with Apigility. Im trying to configure doctrine-orm-module. When i tried to run the command below and getting this error $ cd /var/www/apigility/zf-apigility-skeleton/vendor/doctrine/doctrine-module/bin $ php doctrine-module.php Error is: PHP Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.cli' in /var/www/apigility/zf-apigility

What is the syntax for a multi-table delete on a MySQL database using Doctrine?

半城伤御伤魂 提交于 2019-12-24 01:27:12
问题 Using Doctrine, I am trying to delete records in a single table based on data gathered from multiple tables. 'companies_groups' is an association table linking 'companies' to 'groups'. I want to delete all records in this table linked to a specific company, with the restriction that only 'companies_groups' records linked to a 'public' group will be deleted. If I were to write this in pure SQL, it would look something like this: DELETE companies_groups FROM companies_groups, groups WHERE

Multiple update queries in doctrine and symfony2

纵然是瞬间 提交于 2019-12-24 00:52:39
问题 I've tried to do this in several ways but i can't find the exact syntax for it to work. My latest attempt is below (in a Symfony2 Entity Repository class): public function updateOrdering($new_order, $evaluation_id) { $qb = $this->createQueryBuilder('IddpRplusBundle:Answer'); foreach($new_order as $item){ $id = $item['id']; $answernr = $item['answernr']; $q = $qb->update('IddpRplusBundle:Answer a') ->set('a.answernr', $answernr) ->where('a.id = :id') ->getQuery() ->execute() ; } } The error is

Write “NOT IN” in Doctrine Query Language

為{幸葍}努か 提交于 2019-12-24 00:46:50
问题 I have two tables company(id, ...) and company_has_wtax(company_id, ....) . I need to get all companies that are not in company_has_wtax table. In raw SQL should be something like: SELECT id FROM company LEFT JOIN (company_has_wtax) ON company.id = company_has_wtax.company_id But I don't know how to build this on DQL for Doctrine, any help? Added method to repository and call it from Controller This is the code I made after the answer leave by @Javad: public function findCompanyByDocument() {

Doctrine join bypass lazy loading

只愿长相守 提交于 2019-12-24 00:43:56
问题 I just started exploring Symfony2 and I am amazed how many great features it has. I started doing the blog tutorial at: http://tutorial.symblog.co.uk/ but using version 2.1 instead of 2.0 My problem is that i have the following entity for Blog: /** * @ORM\OneToMany(targetEntity="Comment", mappedBy="blog") */ protected $comments; and the following in the Comment entity: /** * @var string $blog * * @ORM\ManyToOne(targetEntity="Blog", inversedBy="comments") * @ORM\JoinColumn(name="blog_id",

Doctrine discriminator map not updating

两盒软妹~` 提交于 2019-12-24 00:34:14
问题 I'm having issues with class table inheritance. I tried adding a class AtmosphereStudentRequest which extends another ServiceRequest . I'm getting the following error: Entity 'Entities\ServiceRequest\AtmosphereStudentRequest' has to be part of the descriminator map of 'Entities\ServiceRequest' to be properly mapped in the inheritance hierachy. Alternatively you can make 'Entities\ServiceRequest\AtmosphereStudentRequest' an abstract class to avoid this exception from occuring. The following

Symfony2 - Doctrine - no changeset in post update

大城市里の小女人 提交于 2019-12-24 00:25:31
问题 So i am sending an email when a certain value on an entity is changed. I only want the email to send after the update in case the update fails for what ever reason. so on the preUpdate I can do this public function preUpdate(LifecycleEventArgs $args){ if ($args->hasChangedField('value') && is_null($args->getOldValue('value'))) { $this->sendEmail(); } } but i need to do this on postUpdate and as these methods are not available on postUpdate i refactored it to look like this: public function

Mapping - Mongodb Embedded Document in Symfony2

天涯浪子 提交于 2019-12-24 00:24:26
问题 I am trying to add a mapping information in Symfony2 using MongoDB as shown here : http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html [at the Adding Information section] But what I want to do is to add an embedded documents as well. Here is a part of my document with embedded documents : "_id" : "", "last_name" :, "first_name" : "", "address" : [ { "Street" : "", "City" : "", "Zip_Code" : "", "Country": "" } ], "company" : "" "purshaed_items" : [ { "items_id" : "",

doctrine how to write WhereIn() with another sql query inside

一笑奈何 提交于 2019-12-24 00:12:32
问题 i have the folowing query in SQL ... where group_id IN (select group_id from alert where monitor_id = 4); I want to write it in Doctrine but i don't know how to add the IN select into WHEREIN() clause ! any idea ? this is what i did $q = $this->createQuery('u') ->select('u.email_address') ->distinct(true) // ->from('sf_guard_user u') ->innerJoin('u.sfGuardUserGroup ug') ->where('ug.group_id IN(select group_id from alert where monitor_id=?',$monitor); $q->execute(); In the sfGuardUserTable