Selecting data from the database in PHPlaravel is to add time conditions and various conditions

Note: The get function should be added after additional conditions.

1、public function getForDataTable($startTime,$endTime)
{
return $this->query()
->with('a','b')
->select([
'table_name.id',
'table_name.monitor_time',
])
->whereBetween('monitor_time', [$startTime, $endTime])//增加时间条件
->get();

2、$result = Model::whereIn(/*条件1*/)
->whereNotIn(/*条件2*/)
->whereBetween(/*条件3*/)
->where(/*条件4*/)
->orderBy()
->get()

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325796813&siteId=291194637