美文网首页
thinkphp模型

thinkphp模型

作者: 咸鱼前端 | 来源:发表于2019-08-21 15:15 被阅读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);
}
}

相关文章

网友评论

      本文标题:thinkphp模型

      本文链接:https://www.haomeiwen.com/subject/pytisctx.html