# 进阶篇六 TP5类库的封装和使用 ## EditData快捷类库的使用方法 ~~~ $paramList = [ "company" => "company/s", "address" => "address/s", "contacts" => "contacts/s", "jobs" => "jobs/s", "mobile" => "mobile/s", "tencent_code" => "tencent_code/s", "desc" => "desc/s", "event_key" => "event_key/n", ]; $validate_name = "base/system/SystemApply"; $model_name = 'base/system/SystemApply'; $editData = EditData::instance(); $re = $editData ->setParameter($paramList) ->setAppend(["append" => "this is append"]) ->setValidate($validate_name) ->setModel($model_name) ->save();; return $re ? ReturnCode::jsonCode(1001) : ReturnCode::jsonCode(1003); ~~~ ## ReturnCode快捷类库的使用方法 接上 ~~~ return $re ? ReturnCode::jsonCode(1001):ReturnCode::jsonCode(1003); ~~~ ## DatabaseUpgrade 首先修改 数据库链接信息 ~~~ /** * 设置比对更新的数据库 * Power: Mikkle * Email:776329498@qq.com * @param string $updateDatabaseName * @param string $originDatabaseName */ protected function setUpdateDb($updateDatabaseName="update",$originDatabaseName = "origin"){ $this->originDatabaseName = $originDatabaseName; $this->updateDatabaseName = $updateDatabaseName; $originConnect = "mysql://root:123456@127.0.0.1:3306/{$this->originDatabaseName}#utf8"; $updateConnect = "mysql://root:123456@127.0.0.1:3306/{$updateDatabaseName}#utf8"; $this->originDb=Db::connect($originConnect); $this->updateDb=Db::connect($updateConnect); } ~~~ 然后就可以使用数据库比对 ~~~ //对比 DatabaseUpgrade::instance()->getDiffer("new","old"); //更新 DatabaseUpgrade::instance()->updateDatabase("new",,"old"); ~~~ 感谢大家关注 交流请加QQ群 321449759 ![](https://box.kancloud.cn/3499008a08e64306c68873288092a057_286x340.png)