Hi,

The best possible way to find the count is to use findCount() method in the
following way:

$condition = array("Provide the condition here..")
$count = $this->ModelName->findCount($condition); // pass the condition here

All other methods, I believe, are not in 100% conformance to the CAKEPHP
framework and its documentation thereof.

Thanks

Roy

On Sat, Aug 8, 2009 at 1:29 PM, Walther <[email protected]> wrote:

>
> You shouldn't be using the Query method unless you are doing very very
> custom queries. Which your not.
>
> At the moment you have the overhead of CakePHP, but your not actually
> using the framework.
>
> I think you should read through the entire CakeBook (Again if you've
> already done so) and concentrate on the models section, all your
> answers are right there.
>
> On Aug 7, 11:15 am, albe <[email protected]> wrote:
> > I have found a solution in this way:
> >
> > $post['Post']['haswarnings'] = count($this->Warning->query("SELECT  *
> > FROM `db`.`warnings` WHERE `post_id` ='".$post_id."'"));
> >
> > Thank you, anyhow!
> >
> > On 7 Ago, 01:32, albe <[email protected]> wrote:
> >
> > > Hi everybody!
> > > maybe my problem is banal but I really don't know how to solve it:
> >
> > > I wrote a query in a controller and put the result in a variable, in
> > > this way:
> >
> > > $variable['Model']['field'] = ($this->Model2->query("SELECT COUNT
> > > ( * )...");
> >
> > > The result of the query is something like this:
> >
> > > Array
> > > (
> > >     [0] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >                     [COUNT( * )] => 1
> > >                 )
> >
> > >         )
> >
> > > )
> >
> > > Since I have to use this result in the relative view in order to make
> > > comparisons (if $variable.Model.field > 0) I need the PURE NUMBER,
> > > cleaned by the structure posted above.
> > > Otherwise the comparisons wouldn't be correct!
> > > Thank you in advance...
> >
>


-- 
Dibyendu Mitra Roy
Web Development Consultant
Kolkata
India
Alt. E-mail: [email protected]
Mobile: +919830811327
Residence: 91-33-30422096

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to