Helo!!, i need, help me please i'm confused with this query, sorry for my english :(
I have this query and work fine
$mensajes = DB::table('users as U')
->where('R.c_id_fk', '=', $c_id)
->leftJoin('mensajes_reply as R', 'R.user_id_fk', '=', 'U.id')
->select('R.cr_id as id_mensaje','R.time as fecha','R.reply as mensaje','U.primer_nombre as nombre','U.apellido_paterno as apellido')
->orderBy('R.cr_id', 'asc')
->take(10)
->get();
But i take last 10 rows with orderby desc, but show data i need in ordeby asc, i try with raw how read in old forum but y can't understand how convert this to raw form how this
$users = DB::table(DB::raw('('.
DB::table('foo')->orderBy('bar', 'desc')->take(10)->toSql()
.') foo'))->orderBy('bar', 'asc')->get();
Because i use name as other name and this confused me
Thanks!
finally i used
return array_reverse($mensajes, true);
with this i can invert result and this work very well and finally i think that this is better using array_reverse, not to force the sql engine.
Regards! if someone could explain how sql, I would appreciate, to understand it in the same way
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community