本文實例講述了基于thinkPHP類的插入數據庫操作功能。分享給大家供大家參考,具體如下:
基于TP類的插入數據庫操作
/*************************** 插入互動專家的數據** @param object $model        實例化的模型* @param array $Model        獲取到的專家數據* @param int  $result      插入成功后返回的id* @date 2016/02/19* @write zss****************************/private function collect_sp_t_insert($model){    $model = D($model);    //刪除主鍵,防止此操作成為更新操作    unset( $_POST[$model->getPk()]);    //回調處理post數據    if (method_exists($this, '_tigger_post')) {        $this->_tigger_post($_POST);      }    //reate數據    if(false === $model->create()) {      $this->error($model->getError());    }    //保存當前數據對象    if ($result = $model->add()) { //保存成功      // 回調接口      if (method_exists($this, '_tigger_insert')) {        $this->_tigger_insert($result);      }    }}希望本文所述對大家基于ThinkPHP框架的PHP程序設計有所幫助。
新聞熱點
疑難解答
圖片精選