질문을 삭제하지 말아주세요.!
 
1
0
-1

두개의 쿼리의 결과가 같아야 될것 같은데 다릅니다.;;

쿼리 빌더로 조회할때 다른 변수가 들어가나요. ? 


$db_flps=DB::select('SELECT * FROM flps
where updated_at >='.$startdate.'
and updated_at <='.$enddate.'
and user_id = '.$value→user_id);


array(1) { [0]=> object(stdClass)#264 (10) { ["id"]=> int(106) ["user_id"]=> int(2) ["user_name"]=> string(9) "===" ["banner_id"]=> NULL ["thumbnail"]=> string(80) "http://m.wikitree.co.kr/webdata/editor/201705/17/img_20170517142406_6c9f8910.jpg" ["message"]=> string(15) "김성태 웩!!" ["url"]=> string(32) "=======" ["fb_id"]=> string(32) "===" ["created_at"]=> string(19) "2017-05-18 11:23:03" ["updated_at"]=> string(19) "2017-05-19 15:42:21" } }





$flps = Flp::where('updated_at','>=',$startdate)
->where('updated_at','<=',$enddate)
->where('user_id','=',$value->user_id)->get();


object(Illuminate\Database\Eloquent\Collection)#260 (1) { ["items":protected]=> array(0) { } } NULL
    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      눈으로 보기엔 별 문제를 못찾겠는데, 엘로퀀트 쿼리 빌더가 빌드한 SQL 문장을 확인해 보시겠어요?


      // routes/web.php
      
      
      DB::listen(function (\Illuminate\Database\Events\QueryExecuted $query) {
          dump($query);
      });
      
      Route::get('test', function () {
          return App\User::where('created_at', '>=', '2017-01-01')
              ->where('created_at', '<=', '2017-12-31')
              ->get();
      });
      
      
      // Results
      
      
      QueryExecuted {#106 ▼
        +sql: "select * from "users" where "created_at" >= ? and "created_at" <= ?"
        +bindings: array:2 [▶]
        +time: 0.57
        +connection: SQLiteConnection {#107 ▶}
        +connectionName: "sqlite"
      
      }
      
      [
      	{
      		"id":1,"name":"김고객",
      		"email":"user@example.com",
      		"created_at":"2017-01-24 01:33:58",
      		"updated_at":"2017-01-24 01:33:58"
      	}
      ]
        CommentAdd your comment...