Hey everyone! agian :)
I'm having another problem now, this time with custom SQL queries. I
want to get the a count of how many sounds a user ID has uploaded into
the database, this is the SQL query:
SELECT count(*) as c
FROM data_points p join des_walks w
WHERE p.des_walk_id = w.id AND w.com_user_id = 1
The com_user_id would come from my HTMLsetelct in the view.
What I'm stuck on is getting this query submitted and then being able
to use the $result. Heres my controller code:
function index()
{
$this->DataPoint->recursive = 0;
$this->set('datapoints', $this->DataPoint->findAll());
$comUser = $this->ComUser->generateList('id');
$this->set('comUser', $comUser);
$sql = 'SELECT count(*) as c '
. ' FROM data_points p join des_walks w '
. ' WHERE p.des_walk_id = w.id AND w.com_user_id = ' .$comUser;
$result = $this->DataPoint->query($sql);
$this->set('data', $this->DataPoint->query($sql));
print_r($data);
}
I think I'm meant to get an array from the query() function but when I
try to check using print_r I get the following error:
Notice: Undefined variable: data in /Library/WebServer/Documents/cake/
app/controllers/data_points_controller.php on line 25
Should the print_r be in the controller or should that be in the view?
I'm sure I'm doing something wrong and I've been on the forum for the
last hour looking for an answer but now I'm completely stuck
thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---