Assign SQL Query to a Variable

0

I have this Consultation:

$result = DB::table('cliente')
      ->select(DB::raw("CONCAT( TRIM(SUBSTRING( NombreCliente,1,1) ), TRIM(SUBSTRING( NombreCliente, locate( ' ',NombreCliente), 2) ) ) AS INICIALES"))
      ->get();

I get the following results:

I would like to assign those values to each corresponding Variable and I do it in the following way:

 foreach($result as $in)
             {    
              <p>'.$in->INICIALES.'</p>
             }
  

The problem is that I do not know how to do so that each name carries its   corresponding initials, since it prints me 1 name with ALL the   initials ...

    
asked by arch 15.06.2018 в 01:18
source

0 answers