I'm using select
method of laravel QB and I want to get MYSql
command of that's created.
Laravel QB:
public function scopeiOS( $query ){
$result = $query->select( DB::raw('count(`platform`) as iOS' ) ) ->where( 'platform' , '=', 'iOS' ) ->pluck('iOS');
}
toSql()
is not member of that function.
I don't know about toSql()
but if you want to get the query created then you might want to look at the logs of the queries executed for that request.
$queries = DB::getQueryLog();
dd($queries);
Or get the last query executed:
$queries = DB::getQueryLog();
$last_query = end($queries);
Or maybe (warning untested code)
public function scopeiOS( Illuminate\Database\Query\Builder $query ){
$result = $query->select( DB::raw('count(`platform`) as iOS' ) )
->where( 'platform' , '=', 'iOS' )
->pluck('iOS');
}
Check this for more information on toSql()
.
/**
* Get the SQL representation of the query.
*
* @return string
*/
public function toSql()
{
return $this->grammar->compileSelect($this);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.