Data Add function instance
Data add public function NewData ($strName = "") {if (is_post) { ///If user submits data $model = D ("$strName"); if (! $model->create ()) { //If the creation fails to indicate that the validation did not pass the output error message $info = Array ( "info" = = "{$model->geterror () } ", " status "=" n ", ); $this->ajaxreturn ($info, ' json '); Exit (); } else { if ($model->add ()) { $info = array ( "info" = = "Congratulations on the successful operation! ", " status "=" Y ", ); $this->ajaxreturn ($info, ' json '); } else { $info = array ( "info" and "=" operation failed!) ", " status "=" n ", ); $this->ajaxreturn ($info, ' json ');}}}
Data Update Function instance
Data Update public function Update ($strName = "") { if (is_post) { ///If user submits data $model = D ("$strName"); if (! $model->create ()) { //If the creation fails to indicate that the validation did not pass the output error message $info = Array ( "info" = = "{$model->geterror () } ", " status "=" n ", ); $this->ajaxreturn ($info, ' json '); Exit (); } else { if ($model->save ()) { $info = array ( "info" = = "Congratulations on the successful operation! ", " status "=" Y ", ); $this->ajaxreturn ($info, ' json '); } else { $info = array ( "info" and "=" operation failed!) ", " status "=" n ", ); $this->ajaxreturn ($info, ' json ');}}}
Data deletion function instance
Data Delete public function Delete ($strNmae = ") { if (is_post) { $id = I (' post.id '); if (!empty ($id)) { //user submits data delete current id $model = D ("$strName"); $result = $model->delete ("$id"); if ($result!== false) { $info = array ( "info" = "=" Operation succeeded!) ", " status "=" Y ", ); $this->ajaxreturn ($info, ' json '); } else{ $info = Array ( "info" = "=" Operation failed!) ", " status "=" n ", ); $this->ajaxreturn ($info, ' json ');}}}