Recently done a project, which has the demand, requires us to achieve this function: when the goods are sold, the following small edit the core code, aspects of learning.
HTML code omitted .....
Model code omitted .....
The core code looks like this:
* *-------------------------------------------------* Modify Status Public * AUTHOR:LZP time:--*------------------------- ------------------------*/Public Function changestateaction () {$id = $_request[' id '); $result = $this->changeconfir
Mstate ($id);
if ($result) {$this->success ("modified successfully");} else {$this->error ("Modify failed");} Private Function Changeconfirmstate ($id) {$reg = $this->pricemodel->selectprice ([' id ' =>[' eq ', $id]]); $rel = $
This->demandmodel->selectdemand ([' id ' =>[' eq ', $reg [] [' demand_id ']]]);
$demand _id = $reg [] [' demand_id '];
$reg [' demand '] = $this->pricemodel->selectprice ([' demand_id ' =>[' eq ', $demand _id]]); foreach ($reg [' demand '] as $key => $value) {if ($value [' phone '] = = $reg [] [' phone ']] {unset ($reg [' demand '] [$key]);}
else{$new [] = $value [' Phone '];}
$new = [' => ' ******** ']; if (Time ()-strtotime ($rel [] [create_time]) >) {echo <script>alert (' timed out! ');
History.back ();</script> ";
Die }else if (Strtotime ($rel [] finish_tIME '] >) {echo <script>alert (' Closed! ');
History.back ();</script> ";
Die }else{$data _demand = [' is_available ' =>, ' finish_time ' => date ("y-m-d h:i:s")]; $result [' price '] = $this->pri
Cemodel->saveprice ([' id ' =>[' eq ', $id]], [' State ' =>]);
$result [' demadn '] = $this->demandmodel->savedemand ([' id ' =>[' eq ', $reg [] [' demand_id ']]], $data _demand);
$mobile = Implode (",", $new);
$content = "This demand has been sold, next time Yo!"; Smsapp ($mobile, $content);
Send text message return $result; }
}
The code above is a small part of the code to put together the core, the code is also simple, so did not write too many comments, everyone in the reference process encountered any problems, welcome to my message, small series will promptly reply to everyone, in this very grateful to the cloud Habitat Community support site!