pomm-project / ModelManager

Model Manager for the Pomm database framework.
MIT License
66 stars 27 forks source link

Error docs #68

Closed maitrepylos closed 8 years ago

maitrepylos commented 8 years ago

Salut, dans le code suivant, l'accesseur $my_entity->get('field1'); vaut également 2 ? non ?

<?php
//…
class MyEntity extends FlexibleEntity
{
    public function getField1()
    {
        return $this->get('field1') * 2;
    }
}
//…
$my_entity = new MyEntity(['field1' => 1]);
$my_entity->field1;         // 2
$my_entity['field1'];       // 2
$my_entity->get('field1');  // 1
$my_entity->getField1();    // 2
`
chanmix51 commented 8 years ago

Here is a translation of the question:

Hello, in the following code, the accessor $my_entity->get('field1'); also returns one no ?

The generic get() method bypasses any defined accessors, so it always return the raw value, which is handy when one need to pass arguments to SQL queries. So it returns 1.

maitrepylos commented 8 years ago

Sorry I did not read farther the documentation. Personally I find that it is confusing. I would thus limit myself to two methods for getter methods.

Thank you.