Splithead
Splithead

Reputation: 11

Zend hydrator and underscore separated key

I'am looking for an option to hydrate my rows and keep only the value after the first underscore in order to get this :

Table :

user_id
user_name

Model

function getId()
function getName()

If I use the defaults paramaters my model functions are :

getUserId()
getUserName

Upvotes: 1

Views: 132

Answers (1)

Igorock
Igorock

Reputation: 2901

You should create your hydrator like this:

$hydrator = new Zend\Stdlib\Hydrator\ClassMethods(); //without passing false to constructor

ClassMethods has a property $underscoreSeparatedKeys which is true by default.

Upvotes: 1

Related Questions