doctrine

With Doctrine what are the benefits of using DQL over SQL?

﹥>﹥吖頭↗ 提交于 2019-12-12 08:49:13
问题 Can someone provide me a couple clear (fact supported) reasons to use/learn DQL vs. SQL when needing a custom query while working with Doctrine Classes? I find that if I cannot use an ORM's built-in relational functionality to achieve something I usually write a custom method in the extended Doctrine or DoctrineTable class. In this method write the needed it in straight SQL (using PDO with proper prepared statements/injection protection, etc...). DQL seems like additional language to learn

Doctrine2: Arbitrary join and single table inheritance

↘锁芯ラ 提交于 2019-12-12 08:27:22
问题 Note: This is an ORM limitation reported on the project's issue tracker I'm facing an issue building a DQL query using the arbitrary join syntax introduced in Doctrine 2.3 on an entity class which is the root of a hierarchy. Given these classes: A - no inheritance B1 - abstract, root of a hierarchy, discriminator column is named 'type' I setup a query builder like this: $qb->select('a.id AS idA, b.id AS idB') ->from('\Entity\A', 'a') ->leftJoin('\Entity\B1', 'b', \Doctrine\ORM\Query\Expr\Join

How can I resolve this doctrine memory issue

社会主义新天地 提交于 2019-12-12 06:28:01
问题 The following code iterates over a table which has ~1,000,000 rows. I was advised to use Doctrine's iterateResult() method to avoid memory issues (docs) : $batchSize = 1000; $i = 0; $q = $em->createQuery('SELECT i from MyBundle:Items i WHERE i.imgSize IS NULL'); $results = array(); $iterableResult = $q->iterate(); while (($row = $iterableResult->next()) !== false) { $results[]=$row[0]; $em->detach($row[0]); if (($i % $batchSize) === 0) { $em->clear(); // allegedly detaches all objects from

mysql query with join

百般思念 提交于 2019-12-12 06:24:37
问题 this is my database: I would retrieve all records in richiestepreventivo where idImpresa==xx and all the data in privati where privati.id==richiestepreventivo.idPrivato. Can you explain me how I have to set the query with join? Thanks. 回答1: SELECT * FROM privati AS p INNER JOIN richiestepreventivo AS r ON p.id = r.idPrivato WHERE r.idImpresa = xx Are you asking for a simple inner join 回答2: SELECT r.id, p.data FROM richiestepreventivo r JOIN privati p ON p.id = r.idPrivato WHERE r.id = XX; 来源:

Symfony2: how to add a Doctrine Entity Array to FormBuilder

﹥>﹥吖頭↗ 提交于 2019-12-12 05:58:19
问题 i'm working with Symfony and Doctrine, i have a function that will select rows based on specific criteria: $entities = $repository->getSomeEntities(); now i want to render those entities in a choice list, i checked the entity FormType but i couldn't achieve what i'm looking for. Example: $builder->add('id','entity', array( 'class' => 'Path\To\Entity', 'property' => 'id' )); the above code works fine except it selects all the Entities. i checked Symfony documentation http://symfony.com/doc

MySQL - How to track every query? [duplicate]

你。 提交于 2019-12-12 05:48:53
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to enable MySQL Query Log? Is there a way to track every SQL query in MySQL? Im using Doctrine ORM to build entities and fetch them from database, and would like to see what queries is Doctrine producing. So when I refresh a webpage that uses Doctrine ORM to fetch some data from database, where could I see queries executed in database? Is this possible? 回答1: Enable MySQL's general query log: The general

Codeigniter and Doctrine 500 internal error

让人想犯罪 __ 提交于 2019-12-12 05:42:19
问题 I've tried to combine Doctrine with Codeigniter and I'm almost there, I think. The version of Codeigniter is 2.0.2 and from Doctrine is 2.0.0. The problem is now that I get an 500 internal server error using the flush() method of Doctrine. I am following a tutorial (http://wildlyinaccurate.com/integrating-doctrine-2-with-codeigniter-2/) to install doctrine with codeigniter. But at the last step it just fails and I don't know why. This is my code in my controller: $app = new models\application

Using the ServiceLocator in ZF2 with Doctrine 2 from/in a Custom Class?

我怕爱的太早我们不能终老 提交于 2019-12-12 05:42:14
问题 i have a little problem using doctrine 2 in Zend Framework 2 i have custome class that i use to manipulate doctrine generated model (basically to inject data and populate), to make that work i need the entity manager which is available through the service manager as indicated in Jason Grimes tutorial here http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/. In his tutorial it works (i tested it) as the ServiceLocator is called from a controller class, but for the

Doctrine 2 Discriminator Inheritance Mapping leads to findBy methods not working

ε祈祈猫儿з 提交于 2019-12-12 05:37:48
问题 i have 2 entities, one as a main super class which consist of the discrimators etc and one which extends this super class... so that i can record all actions in one table called Action. my discrimator entity: namespace Entities\Members; /** * @Entity * @Table(name="actions") * @MappedSuperClass * @InheritanceType("JOINED") * @DiscriminatorColumn(name="action_type", type="string") * @DiscriminatorMap({"comments" = "Comments", "blog" = "Blog"}) * @HasLifecycleCallbacksIndex */ class Action { /*

Doctrine: How to insert foreign key value

你说的曾经没有我的故事 提交于 2019-12-12 04:53:34
问题 I have two tables in my database: sliders and images . One slider can have many images, so the structure of tables is: --------- -------- | SLIDERS | | IMAGES | --------- -------- | id | | id | --------- -------- | title | | title | --------- -------- | sid | -------- SID is a foreign key associated to id in "SLIDERS" table. In entities I put bidirectional relationships OneToMany and ManyToOne , so fetched Slider result would contain Images Objects that belong to him, and Images would contain