문제

I have seen both of these syntaxes for adding constraints to an existing Fluent/Eloquent $query (such as when appending a constraint based on a conditional):

$query = $query->where( 'id','=',1 );

and

$query->where( 'id','=',1 );

Is there any practical difference between them?

도움이 되었습니까?

해결책

No difference at all. In this case $query is an object and it will internally set the filter, but it also returns itself, to provide chaining:

$query->where( 'id','=',1 )->where( 'name','=', 'antonio' );

So those two are exactly the same.

$query = $query->where( 'id','=',1 );
$query->where( 'id','=',1 );
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top