thinkphp模型

2019-08-21  本文已影响0人  咸鱼前端

<?php

namespace app\index\controller;

use app\index\model\Student;

//模型是和一张数据表绑定的
class Demo6
{
//1.单条查询
public function get()
{
// dump(Student::get(51));
//用查询构造器创建更加复杂的查询
res = Student::field('id,name,password') ->where('id', 51) ->find(); // Student:: 等价于 Db::table('student') dump(res instanceof Student);
}

//2.多条查询
public function all()
{

// dump(Student::all([1, 2, 3, 4]));
res = Student::field(['id', 'name' => 'lzq']) ->where('id', 'in', '1,2,3,4,5,6,7,8,9,10,11,12,13,14') ->select(); dump(res);
}
}

上一篇 下一篇

猜你喜欢

热点阅读