Like you said, not the best way to do it. But here it is:
'select * from destinations where DestinationName="'.$destination."''
// or should also work
"select * from destinations where DestinationName=\"$destination\""
This could open you up to SQL injection, so just be aware.
This is how to do it using a Model file.
$data = Destinations::where(DestinationName, '=' ,$destination);
The most basic model file.
class Destinations extends Eloquent { }
The lower-case, plural name of the class will be used as the table name unless another name is explicitly specified.
Can over write and set name if wanted by adding the following in the class - protected $table = 'db-table-name';
More info and some example code, http://laravel.com/docs/4.2/eloquent#basic-usage
Hope that helps.
Thanks for your reply.
Should I pass this though the real escape string then?
I have found this to escape variables and it seems to work.
$data = \DB::select(\DB::raw("SELECT * FROM destinations WHERE DestinationName = :destination"), array( 'destination' => $destination));
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community