1
Good morning gentlemen I am starting my studies in Latin working with version 6 of the framework, and I came across problem that is probably a detail that I missed in my code.
When trying to perform a select in the database from a requeste I have a syntax error of mariadb.
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.`8 Accept-Encoding: gzip, deflate Accept-Language: pt-BR,' at line 1 (SQL: select * from `cities` where `GET /cities?id=1 HTTP/1`.`1 Accept: text/html
My method of controller:
public function cities(Request $request)
{
$cities = \App\Cities::where($request)->get();
return $cities;
}
But if I let the I change to this result I get the result I need.
$cities = \App\Cities::where('id', '=', '1')->get();
I am sending following url to the Standard http://127.0.0.1:8000/Cities? id=1
and when I return $request I get json id "1"
what I need to do with this request before sending the query?
I need Where because in most cases I will have more than a result in the search. Thanks in advance.
Excuse my ignorance but did not fully understand, 'paramtro' is the column of the bank? and that complement after the request would be what? '->yourVariavel_get_ou_post' thanks in advance.
– Andrew Palmeira
@Andrewpalmeira gave an edited answer, see if improved
– PaulinhoCaP
Understood! thank you very much for the explanation, gave straight!
– Andrew Palmeira