Question

I have a table with some fields i want to update all the colums in a particular row, how we can do this?

I want to update this array of data into the table

                 $travel_details=array(
                'userprofile_id'=>$upid,
                'day'=>$data['day'],
                'dayNumeric'=>$daynum,
                'morning_route'=>$morning_route,
                'morning_time'=>$morning_time,
                'evening_route'=>$evening_route,
                'evening_time'=>$evening_time,
                'traveller' =>$traveller
            );

i use one code with some conditions

          $this->Singleroute->updateAll($travel_details,array('Singleroute.userprofile_id'=>$upid,'Singleroute.daynumeric'=>$daynum,
            'Singleroute.day'=>$data['day']));

but this code is not working..is there any way to update al;l the fields in a row? this is the table structure

Was it helpful?

Solution

$travel_details should be like this

$travel_details['Singleroute']=array(
                'userprofile_id'=>$upid,
                'day'=>$data['day'],
                'dayNumeric'=>$daynum,
                'morning_route'=>$morning_route,
                'morning_time'=>$morning_time,
                'evening_route'=>$evening_route,
                'evening_time'=>$evening_time,
                'traveller' =>$traveller
            );

you need to specify the model in fields array. NOw run your query

$this->Singleroute->updateAll($travel_details,array('Singleroute.userprofile_id'=>$upid,'Singleroute.daynumeric'=>$daynum,
            'Singleroute.day'=>$data['day']));

Read more for saving data here http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Models.html#saving-your-data

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top