1
I’m wearing the Laravel 5.6
My model is normal
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class MyTable extends Model
{
protected $table = 'myTable';
public $timestamps = false;
}
I’m trying to make a simple query where is to bring 8 records
I’m wearing it like this:
public function getDevice( Request $request ){
$ip = $request->input('ip');
$table = MyTable::where('description', $ip );
echo "<pre>";
print_r($table );
echo "</pre>";
/*
return response()->json($table);
*/
}
But it’s catching up and it’s not bringing the result
Consider the table
id | description| status |
1 | 1 | 0 |
2 | 1 | 1 |
3 | 1 | 0 |
4 | 1 | 1 |
But if I wear it like this
$query DB::select('SELECT * FROM myTable WHERE description = ?', [1]);
or if you bring only one
$table = MyTable::find(1);
$table = MyTable::all();
Works
have tried using single quotes?
$query DB::select("SELECT * FROM myTable WHERE description = '?'", 1);
– Ricardo Pontual
That way it works, but that way
$table = MyTable::where('description', $ip );
doesn’t work– adventistaam