I've a problem... I'm starting to learn how to use CakePHP and I'm
trying to write a new Action in one of my Controllers. I need to
recuperate values sent by a View and validate them.
The idea is: The user makes a reserve to one Official in one Date and
Time. I've to verify if this reserve already exists in my database
when he tries to make another one.
So, I wrote this Action in Reserve Controller:
function verifyReserve($official, $date, $time) {
if($this->Reserve->query("SELECT COUNT(reserves.id) FROM reserves
WHERE official_id='$official' AND reserve_date='$date' AND
reserve_time='$time'") != 0) {
return true;
} else {
return false;
}
}
And into the Action "Add" of the Reserve Controller I wrote this
validade:
if(($this->Reserve->verifyReserve($this->data['Reserve']
['official_id'], $this->data['Reserve']['reserve_date'], $this-
>data['Reserve']['reserve_time'])) == true)
{
$this->Session->setFlash(Already exists an reserve for this official
on this date and time.');
$this->set('officials', $this->Reserve->Official->generateList(null,
'name', null,'{n}.Offical.id','{n}.Official.name'));
$this->set('customers', $this->Reserve->Customer->generateList(null,
'name', null,'{n}.Customer.id','{n}.Customer.name'));
}
However, when I try to make a reserve an error occurs:
Query: verifyReserve
Warning: SQL Error: 1064: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near 'verifyReserve' at line 1 in C:\xampp\htdocs\cake
\cake\libs\model\datasources\dbo_source.php on line 440
Warning: Cannot modify header information - headers already sent by
(output started at C:\xampp\htdocs\cake\cake\basics.php:697) in C:
\xampp\htdocs\cake\cake\libs\controller\controller.php on line 447
Help me, please.
Thanks :o)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment