php - Laravel DB::RAW fetch single -
I am using a quote query in Laravel .. because this query is a bit complicated with builder or lucrative.
I ask the database for 1 person, from where I am using it. The returned result is an array, with something in it .. (see screenshot)
How do I get only the first result? I have tried return data $ ['person'] = db :: select (db :: raw ($ person)) [0]; From which I get the following error:
Feedback content A string or object should implement __toString (), "Object". Return Data ['Person'] = DB :: Select (DB :: Raw ($ person)) - & gt; First ();
which is telling me that it is not applicable for such queries first ..
this is the query SELECT Companies on JOIN companies from nickname, firstname, lastname, age, title, photo, companies.name, cities.name, trickshot people.ind = persons.company_id Join cities in cities.id = companies.city_id where CONCAT (first name , Last name) = '{$ Fullname}' and cities. Name = '{$ city}' Thanks!
It is such that you believe in the eLocation that person The model is:
person :: Select (.., 'company.co.name as company', 'city as cit.name') - & gt; Join ('companies as companies', 'comp.id', '=', 'individuals.company_id') - & gt; ('Cit.name', $ city) - & gt; Where (DB :: Raw ('Cockat (First Name)' ('CIT', '=', 'Comp., Last Name)'), $ Full Name) - & gt; first (); If you need to set up more data, instead I will create a DB view for this.
return data $ ['person'] = db :: select (db :: raw ($ person)) [0]; From which I get the following error:
Feedback content A string or object should implement __toString (), "Object". Return Data ['Person'] = DB :: Select (DB :: Raw ($ person)) - & gt; First ();
which is telling me that it is not applicable for such queries first ..
this is the query SELECT Companies on JOIN companies from nickname, firstname, lastname, age, title, photo, companies.name, cities.name, trickshot people.ind = persons.company_id Join cities in cities.id = companies.city_id where CONCAT (first name , Last name) = '{$ Fullname}' and cities. Name = '{$ city}' Thanks!
It is such that you believe in the eLocation that person The model is:
person :: Select (.., 'company.co.name as company', 'city as cit.name') - & gt; Join ('companies as companies', 'comp.id', '=', 'individuals.company_id') - & gt; ('Cit.name', $ city) - & gt; Where (DB :: Raw ('Cockat (First Name)' ('CIT', '=', 'Comp., Last Name)'), $ Full Name) - & gt; first (); If you need to set up more data, instead I will create a DB view for this.
Comments
Post a Comment