1

I want to fetch data from a view in Oracle, SQL query in controller is as follows :

$cnx = DB::connection('oracle');
$outs = $cnx->select("SELECT client FROM M_CLIENT 
                      WHERE INSTR(STATUS, 'OUT')>0 
                      AND DPTID=:dptid",['dptid'=>$dptId[0]->dptid]);

and the return : return view('clients.home', compact('outs'));

But if I loop though outs in controller

for ($i=0; $i < count($outs); $i++) { 
            print_r($outs[$i]->client );
            echo '<br/>';
        }

I get the list of clients as wanted

While in blade, I tried :

@for ($i = 0; $i < 3; $i++)
   <tr>
     <td> {{ $outs[$i]['client'] }} </td>
   </tr>
@endfor

and :

@foreach($outs as $out)
   <tr>
     <td> {{ $out['client'] }} </td>
   </tr>
@endforeach

and :

@foreach($outs as $out)
   <tr>
     <td> {{ $out->client }} </td>
   </tr>
@endforeach

I get a blank page with 500 server error.

PS: The output of dd($outs) is :

array:7 [▼
0 => {#1290 ▼
    +"client": "Client1: OUT"
  }..
0

1 Answer 1

0

Problem fixed

Forgot about /storage/logs/laravel.log where log errors are written.. Turned out some code wrapped in comment in blade was being executed, and The right code in blade is

@foreach($outs as $out)
   <tr>
     <td> {{ $out->client }} </td>
   </tr>
@endforeach
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.