Now, I clicked the link, which is a post request. The parameter is passed by get, and the actionTripDays method is executed three times. Three pieces of data are inserted in the table and should be executed only once, insert a piece of data. What is this ?? Please help, but I am in, if, dump ($ position... now the situation is, I clicked
a
Link, yes
post
Request. The parameter is
get
Passed,
actionTripDays
The method is executed three times. Three data entries are inserted in the table, and only one data entry is executed. What is the reason ?? Help
But I am,if
,dump($position)
But only one output.
$ LogId, 'position' => 'end'])?> "Class =" add-one-day "data-method =" post "rel =" nofollow "> + add the next day public function actionTripDays ($ id) {$ model = $ this-> findModel ($ id); // The first write is as follows: if (! Empty ($ position = Yii: $ app-> request-> get ('position', '') // if (Yii:: $ app-> request-> getIsPost ()&&! Empty ($ position = Yii: $ app-> request-> get ('position', '') {// dump (Yii :: $ app-> request-> get ('position', ''); // exit; TravelDay: addDay ($ position, $ model-> id );} else {TravelDay: initDay ($ model-> id);} $ days = TravelDay: find () -> where (['travel _ log_id '=> $ model-> id])-> orderBy (['order' => SORT_ASC])-> all (); $ images = TravelImg: find ()-> where (['travel _ log_id '=> $ model-> id]) -> orderBy (['order' => SORT_ASC])-> all (); return $ this-> render ('trip-days ', ['images' => $ images, 'days' => $ days, 'logid' => $ model-> id,]);}
Reply content:
Now, I clicked.a
Link, yespost
Request. The parameter isget
Passed,actionTripDays
The method is executed three times. Three data entries are inserted in the table, and only one data entry is executed. What is the reason ?? Help
But I am,if
,dump($position)
But only one output.
$ LogId, 'position' => 'end'])?> "Class =" add-one-day "data-method =" post "rel =" nofollow "> + add the next day public function actionTripDays ($ id) {$ model = $ this-> findModel ($ id); // The first write is as follows: if (! Empty ($ position = Yii: $ app-> request-> get ('position', '') // if (Yii:: $ app-> request-> getIsPost ()&&! Empty ($ position = Yii: $ app-> request-> get ('position', '') {// dump (Yii :: $ app-> request-> get ('position', ''); // exit; TravelDay: addDay ($ position, $ model-> id );} else {TravelDay: initDay ($ model-> id);} $ days = TravelDay: find () -> where (['travel _ log_id '=> $ model-> id])-> orderBy (['order' => SORT_ASC])-> all (); $ images = TravelImg: find ()-> where (['travel _ log_id '=> $ model-> id]) -> orderBy (['order' => SORT_ASC])-> all (); return $ this-> render ('trip-days ', ['images' => $ images, 'days' => $ days, 'logid' => $ model-> id,]);}
I am not answering this question. I want to ask how yii sets the Request Method for element.