I have an entity generated using doctrine in command line. It is as below -
/**
* @var string
*
* @ORM\Column(name="COUNTRY_ID", type="string", length=2)
*/
private $cOUNTRYID;
In the database the column name is COUNTRY_ID
and the SQL result will give assoc. array with COUNTRY_ID
as key and its name as value.
My requirement is to have display name of SQL result to camel case. for example COUNTRY_ID
should be countryId
. Is there any config ready available in doctrine file to do this?.
If you mean with display name the class property name, then you can do it like this:
The
name="COUNTRY_ID"
in your Column definition is the column name that doctrine uses to find it in the table (table column name).The property name
$countryId
is the name of the property that Doctrine uses to bind the result of the query to. So if you want the class property to be in camel case you simply need to declare the property name camel cased.You have to implement a naming strategy to get camelCase autogenerated column names, as explained in Doctrine documentation.
Make a class to get camelCase name for your column names, CamelCaseNamingStrategy.php:
Then register this new class as a service, and add it to your config.yml: