This is basic stuff that is covered very adequately in the online guide: http://book.cakephp.org/view/1031/Saving-Your-Data
The key difference between an insert and an update is that if Cake finds a valid id field/value in your data array, it will update that row. If it does not find a valid id field/value, it will do an insert. Bear this in mind when you create your forms. In fact, if you bake a few model/controller/views and look at the code, the secrets are all laid bare. Jeremy Burns [email protected] On 7 May 2010, at 06:51, Narendra Padala wrote: > Hi..! > I am new to cakephp,how to conver the following qyery in to cakephp > please any can help me out. > > $timem _out = date('H:i:s'); > $date = date('Y-d-m'); > > UPDATE Timesheets SET time_out = '$time_out' WHERE id = '2' AND date = > '$date'; > > thanks in advance...! > > > Actually this is my for data. > ---------------------------------------- > > <?php > $user_id = $userId; > $date = date('Y-d-m'); > $time_in = date('H:i:s'); > $time_out = date('H:i:s'); > $time="00:00:00"; > if($cOutCheck!=0) { > e($form->create('Timesheet', > array('action' => 'clockout'))); > e($form->hidden('user_id',array('value'=> > $user_id))); > e($form->hidden('time_out',array('value'=> > $time_out ))); > e($form->hidden('date',array('value'=> > $date))); > e($form->submit('Clock Out')); > e($form->end()); > } > else { > echo "Clock Out"; > } > > ?> > ---------------------------------------------------------------------------------------------------- > > here i need to write that update code please help me out > > > function clockout() { > > $this->Timesheet->create(); > > $currentdate=$this->data['Timesheet']['date']; > $id=$this->data['Timesheet']['user_id']; > > echo "here we want to update the time_out field using this id > (".$id.") and current date ".$currentdate; > > } > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
