Answer the question
In order to leave comments, you need to log in
Why getters and setters in zf3?
Everyone will accept. I just can't understand the meaning of getters and setters in zend entities. Specifically, this is the question.
In fact, the Zend\Db doc offers us something like this option for updating the content in the tuples of the database, which is shown in the code below. And despite the fact that in my Album entity the properties have the protected access modifier, as a result, I can still use the $albumRow->artist = 'New Name'; and besides, in this context, I can't use $albumRow->setArtist('New Name'); instead. .
$adapter = new Adapter($this->config['db']);
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Album());
$table = new TableGateway('album', $adapter, new RowGatewayFeature('id'), $resultSetPrototype);
$results = $table->select(array('id' => 2));
$albumRow = $results->current();
$albumRow->artist = 'New Name';
$albumRow->save();
...
$albumRow->setArtist('New Name');
$albumRow->setTitle('New Title');
$albumRow->save();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question