Brilliant thanks, that debug option is very helpful.  Correct me if
I'm wrong, I'm getting an undefined index error: DataPoint, with this
line:

 <?php echo $data['DataPoint'][0]['count(*)']; ?>

Doesn't these values come from the controller, more specifically this
line?

$this->set('data', $this->DataPoint->query("SELECT count(*) AS c FROM
data_points AS Data_points WHERE data_points.des_walk_id = 1 "));

Hence the use of $data['DataPoint']....


On Jul 9, 1:56 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> this a problem I have also when doing custom query: You have to do the
> following to get your value:
>
> <?php echo $data['DataPoint'][0]['count(*)']; ?>
>
> You can see the structure of the array when you do a
>
> <?php echo debug($data); ?>
>
> On Jul 9, 8:16 am, mussond <[EMAIL PROTECTED]> wrote:
>
> > Thanks :)  I got a working query now that when I use print_r gives me
> > the correct data.
>
> > But I'm having trouble displaying it.
>
> > If I did this in my controller:
>
> >      $this->set('datapoints', $this->DataPoint->findAll());
>
> > I could display the id field like this:
>
> > <?php echo $datapoint['DataPoint']['id']; ?>
>
> > So I thought with my SQL query in the controller:
>
> > $this->set('data', $this->DataPoint->query("SELECT count(*) AS c FROM
> > data_points AS Data_points WHERE data_points.des_walk_id = 1 "));
>
> > I could then display it the same way:
>
> > <?php echo $data['DataPoint']['c']; ?>
>
> > Which doesn't work.
>
> > What am I missing?  How do you display values from and array?
>
> > Thanks
>
> > On Jul 6, 2:49 pm, dakomoon <[EMAIL PROTECTED]> wrote:
>
> > > Yea, you are getting three arrays.  The first array is the array of
> > > different models returned, the second array is the array of different
> > > rows from each model, and the third array are the columns of each
> > > row.  It might help to remember that cake collates result sets into
> > > associative arrays, but since you have no table aliases you cant see
> > > it.  For fun you might try change the query to "SELECT count(*) AS c,
> > > Data_points.somefield FROM data_points AS Data_points..." and you'll
> > > see what I'm talking about.
>
> > > hth


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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