?php namespace app\common\model; use think\Model; use think\Db; class User extends Model{ //開(kāi)啟自動(dòng)完成時(shí)間戳功能 protected $autoWriteTimestamp = true; } ?>
User::update(['name'='安陽(yáng)'],['id'=>1]);
Thinkphp中update方法的源代碼如下:
/** * 更新數(shù)據(jù) * @access public * @param array $data 數(shù)據(jù)數(shù)組 * @param array $where 更新條件 * @param array|true $field 允許字段 * @return $this */ public static function update($data = [], $where = [], $field = null) { $model = new static(); if (!empty($field)) { $model->allowField($field); } $result = $model->isUpdate(true)->save($data, $where); return $model; }
$user=new User; $user->isUpdate(true)->save(['name'='安陽(yáng)'],['id'=>1]);
到此這篇關(guān)于thinkphp5.1的model模型自動(dòng)更新update_time字段實(shí)例講解的文章就介紹到這了,更多相關(guān)thnikphp5.1的model模型自動(dòng)更新update_time字段內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
標(biāo)簽:柳州 唐山 遼陽(yáng) 鶴崗 鷹潭 六安 克拉瑪依 白城
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《thinkphp5.1的model模型自動(dòng)更新update_time字段實(shí)例講解》,本文關(guān)鍵詞 thinkphp5.1,的,model,模型,自動(dòng),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。