Count number of rows for Cakephp querybuilder
<p>I am writing a custom function in a Member controller.
The purpose of the function is this:-</p>

<ol>
<li>First it checks if an id exists in the <code>members</code> table. </li>
<li>If it doesn't exist then it returns 0;  </li>
<li>if it exists, then it checks whether the isActive status is 0 or 1; </li>
<li>if it's 0, then it returns 0, else 1;</li>
</ol>

<p>Now, I am writing the function as these:-</p>

<pre><code>public function memberExist($id)
{
    $query = "SELECT Member.id FROM members AS Member WHERE Member.id = $id AND Member.isActive = 1";
    // Here I want to write something like:
    // if($this-&gt;query($query)-&gt;num_rows()&gt;0) return 1; else return 0;
}
</code></pre>

<p>However, the problem is, I don't now how to get number of rows from query builder(sorry if the name is not exact, I am new to cakephp).</p>

<p><code>$this-&gt;query($query)</code> returns array.</p>

<p>In controller, we can use following method to get number of rows,</p>

<pre><code>$userdata = $this-&gt;Member-&gt;find('count',array('conditions'=&gt;array('Member.id'=&gt;$id, 'Member.isActive'=&gt;1)));
</code></pre>

<p>But how to apply count procedure in the Model?</p>