Laravel 4.2获取当月的记录

时间:2016-04-06 06:21:36

标签: php mysql laravel-4.2

我在项目中遇到问题我正在使用Laravel 4.2

有问题的代码片段。

$xx = xx::where('user_id','=',$user_id)
            ->where('date','>=',$first_day) //$first_day is first day of any month
            ->where('date','<=',$last_day)//$last_day is last day of same month
            ->get();

print_r($xx);die(); 
//records present but empty array for current month but working fine for any previous month

结果

  

Illuminate \ Database \ Eloquent \ Collection Object([items:protected] =&gt; Array())

Laravel上次查询日志

  

数组([query] =&gt; select {from x_xx其中user_id =?和date   =?和date&lt; =? [bindings] =&gt;数组([0] =&gt; 17 [1] =&gt; 2016-04-1 [2] =&gt; 2016-04-30)[时间] =&gt; 0.69)

在mysql phpmyadmin中运行我有15条记录

  

x_xx中选择* user_id = 17和date&gt; =&#39; 2016-04-1&#39;    和date&lt; =&#39; 2016-04-30&#39; //在mysql中找到15条记录

0 个答案:

没有答案