Symfony2 Doctrine Unrecognized field:
For others who still have the problem,
make sur that you have puted the sign '=>
' instead of ',
' when calling the function findOneBy(...)
So instead of :
findOneBy(["code" , "Code-Example"]);
do that :
findOneBy(["code" => "Code-Example"]);
The property name is actually:
private $stadiumID;
So you should do :
$repo->findOneBy(array('stadiumID' => $value));
so change this row:
$criteria = array("StadiumID" =>$stadium['StadiumID']);
to this:
$criteria = array("stadiumID" =>$stadium['StadiumID']);
Doctrine's main role is to connect your application layer(entites) to the database layer(tables). So doctrine tries to translate request comming from the application layer to the database. Even if you named your field in the database "StadiumID"
or "table_name_snake_case"
, when you call findOneBy(array($property => $value))
, doctrine expects $property
to refer to the property name, and it will translate this to SQL to something like 'SELECT FROM .... where StadiumID = :value'