<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Tue Jun 18 20:42:43 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DDC-2318/DDC-2318.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DDC-2318] Count all element</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2318</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I&apos;m sorry if it is not the right place to ask and suggest but I was not sure where to contact you.&lt;/p&gt;

&lt;p&gt;I have been trying to make a pagination of articles without using DQL. For me, it defies the purpose of the ORM to do DQL for things like pagination.&lt;/p&gt;

&lt;p&gt;After some research I found the method findBy() which allows me to select X element starting at position Y.&lt;br/&gt;
Yet, to know the number of pages, I needed to count the number of elements in my database and I didn&apos;t find any count() method in the Entity Repository.&lt;/p&gt;

&lt;p&gt;I was wondering why there is no count method ?&lt;/p&gt;

&lt;p&gt;Moreover, I did my own entity Repository that extends the default one to have a count method like this :&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;use Doctrine\ORM\EntityRepository;

class CountableEntityRepository &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; EntityRepository {
    
    /**
     * returns the number of entity&apos;s rows
     * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function count() {
        $query = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;createQueryBuilder(&apos;e&apos;)-&amp;gt;select(&apos;count(e)&apos;)-&amp;gt;getQuery();
        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $query-&amp;gt;getSingleScalarResult();
    }
}&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;as I am new to Doctrine I don&apos;t know if this is a good solution, if it is not, could you add a count method to the repository ?&lt;/p&gt;

&lt;p&gt;Thank you very much.&lt;/p&gt;

&lt;p&gt;Regards,&lt;br/&gt;
Benjamin.&lt;/p&gt;</description>
                <environment></environment>
            <key id="14549">DDC-2318</key>
            <summary>Count all element</summary>
                <type id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/newfeature.png">New Feature</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="6" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/closed.png">Closed</status>
                    <resolution id="6">Invalid</resolution>
                    <security id="10000">All</security>
                        <assignee username="ocramius">Marco Pivetta</assignee>
                                <reporter username="xzan">Benjamin</reporter>
                        <labels>
                    </labels>
                <created>Mon, 25 Feb 2013 15:21:19 +0000</created>
                <updated>Mon, 25 Feb 2013 15:27:04 +0000</updated>
                    <resolved>Mon, 25 Feb 2013 15:27:04 +0000</resolved>
                                                                    <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="19684" author="ocramius" created="Mon, 25 Feb 2013 15:26:53 +0000"  >&lt;p&gt;Heya!&lt;/p&gt;

&lt;p&gt;First of all, consider that this is an issue tracker, not a Q&amp;amp;A platform (use StackOverflow, the mailing list or IRC for that). &lt;/p&gt;

&lt;p&gt;Anyway, the use case seems reasonable to me, but consider that Doctrine comes with a powerful paginator ( &lt;a href=&quot;http://docs.doctrine-project.org/en/latest/tutorials/pagination.html&quot; class=&quot;external-link&quot;&gt;http://docs.doctrine-project.org/en/latest/tutorials/pagination.html&lt;/a&gt; )&lt;/p&gt;

&lt;p&gt;I don&apos;t think this logic fits repositories by default.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>