WebsiteModel为自定义模型
use app\ciyuan_back\model\Website as WebsiteModel;
参数为n
n为正整数
$result = WebsiteModel::limit(1)->select();
显示1条记录
$result = WebsiteModel::limit(10)->select();
显示10条记录
不传参
$result = WebsiteModel::limit()->select();
报错:Missing argument 1 for think\db\Query::limit()
参数为0
$result = WebsiteModel::limit(0)->select();显示所有记录
如果想查询所有记录,可以直接使用 $result = WebsiteModel::select();。
参数为-1
$result = WebsiteModel::limit(-1)->select();
报错:SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1