Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get information how doctrine query was build
    text
    copied!<p>I use doctrine 1.2, in symfony 1.4.8 . Here is my code:</p> <pre><code>private function getWithMaxProductsQ($limit){ $query = Doctrine_Query::create() -&gt;select('m.name, COUNT(p.manufacturer_id) AS c') -&gt;from('manufacturer m') -&gt;innerJoin('m.Product p') -&gt;where('p.is_published = 1') -&gt;addWhere('p.is_available = 1') -&gt;groupBy('p.manufacturer_id') -&gt;orderBy('c DESC') -&gt;limit($limit); //die($query-&gt;getSqlQuery()); return $query; } public function getManufacturersForCategoryDeep(Category $cat, $limit = 7){ $ids = $cat-&gt;getDescendantsAndMeIds(); $q = $this-&gt;getWithMaxProductsQ($limit); $q-&gt;innerJoin('p.Category c')-&gt;whereIn('c.id', $ids); die($q-&gt;getSqlQuery()); $mans = $q-&gt;execute(); return $mans; } </code></pre> <p>As you may notice there is <code>die</code> call inside <code>getManufacturersForCategoryDeep</code> which gives me info what query will be executed. Here is sql query:</p> <pre><code>SELECT `m`.`id` AS `m__id`, `m`.`name` AS `m__name`, COUNT(`p`.`manufacturer_id`) AS `p__0` FROM `manufacturer` `m` INNER JOIN `product` `p` ON `m`.`id` = `p`.`manufacturer_id` INNER JOIN `category` `c` ON `p`.`category_id` = `c`.`id` WHERE `m`.`id` IN ('49', '43', '127', '42', '65', '134', '113') AND (`p`.`is_published` = 1 AND `p`.`is_available` = 1 AND `c`.`id` IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)) GROUP BY `p`.`manufacturer_id` ORDER BY `p__0` DESC </code></pre> <p>And I dont know why this line appear in query <code>WHERE m.id IN ('49', '43', '127', '42', '65', '134', '113')</code> I used apc and memcached caching for DQL query parsing caching, but it was disabled a month ago. So how i can find out what is happening with this query ?</p> <p><strong>UPDATE:</strong> this line is dissapears after removal <code>limit()</code> invocation</p> <p><strong>UPDATE2:</strong> here is open bug <a href="http://www.doctrine-project.org/jira/browse/DC-1052?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab" rel="nofollow">http://www.doctrine-project.org/jira/browse/DC-1052?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload