相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
基于thinkPHP類的插入數(shù)據(jù)庫操作功能示例
本文實例講述了基于thinkPHP類的插入數(shù)據(jù)庫操作功能。分享給大家供大家參考,具體如下:
基于TP類的插入數(shù)據(jù)庫操作
/************************** * 插入互動專家的數(shù)據(jù) * * @param object $model 實例化的模型 * @param array $Model 獲取到的專家數(shù)據(jù) * @param int $result 插入成功后返回的id * @date 2016/02/19 * @write zss ****************************/ private function collect_sp_t_insert($model){ $model = D($model); //刪除主鍵,防止此操作成為更新操作 unset( $_POST[$model->getPk()]); //回調(diào)處理post數(shù)據(jù) if (method_exists($this, '_tigger_post')) { $this->_tigger_post($_POST); } //reate數(shù)據(jù) if(false === $model->create()) { $this->error($model->getError()); } //保存當前數(shù)據(jù)對象 if ($result = $model->add()) { //保存成功 // 回調(diào)接口 if (method_exists($this, '_tigger_insert')) { $this->_tigger_insert($result); } } }