I am using doctrine 2 and my entity has variables set like:
Now i want to fill this variables from array using Hydrator like this:
public function fromArray($values)
$hydrator = new \Hydrator\ClassMethodsHydrator();
But after using this function i get error becuase Hydrator tries to call setphoneNumber() instead of setPhone_number() ...
Can you help me how to achieve my goal instead of changing underscores to camelCase?
/** * @ORM\Column(type="string", name="phone_number") */ protected $phoneNumber;
Doctrine would rename your phoneNumber into phone_number anyway when creating your database schema, but by using the name attribute in \Column or \Table Definition you can make sure your name is used.
So in your database table column it's: phone_number
Your entity attribute is called: phoneNumber
So this will usually end up in setPhoneNumber for your setters which is fine.