Thinkphp5 數據庫 查詢 select

// db
// db("user",[],false) 關閉每次使用生成對象

// select() 返回全部數據 數據不存在返回空數組
$res = db("user",[],false)->select();

// find() 返回一條數據,數據不存在返回null
$res = db("user")->where(['id'=>2])->find();

// value() 返回一條數據(某個字段值) , 數據不存在返回null
$res = db('user')->value('name');

// Column() 返回字段所有值,數據不存在返回空數組
$res = db('user')->where(['id'=>10])->column('name');
dump($res);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章