Using get-set and protected property
class Model extends \Phalcon\Mvc\Model
{
protected $prop;
public function getProp()
{
return $this->prop;
}
public function setProp($prop)
{
$this->prop = $prop;
return $this;
}
}
$model = new Model();
**_Protected, Can't access._**
echo $model->prop;
$model->prop = 1;
**_Work can access_**
$model->setProp() OR $model->getProp();
$resultset = Model::find();
foreach ( $resultset as $row ) {
echo $row->prop; //Works
$row->prop = 1;
}
Config
Phalcon 4.0.2 / PHP 7.4.2 / Postgresql 12.1/Nginx 1.16.1
@tidytrax Is this occurring with properties as private as well?
@tidytrax Is this occurring with properties as private as well?
Yes I tested now and private work also, same code above, but with private prop
foreach ( Model::find() as $row ) {
echo $row->prop;
}
@tidytrax thnx. We will have a look at it
@tidytrax thnx. We will have a look at it
Thanks, it's not a big problem, but the postgres boolean(14722) is killing my app.
Could you provide me with some turn around ? like someway to bring all fields as string.
The bug occurs on Model::findFirst() also
I wasn't able to reproduce this. Can you check the type of object you get from the result set?
Maybe the hydrate mode is incorrect?
$resultset->setHydrateMode(
Resultset::HYDRATE_RECORDS
);
$model = UserSession::findFirst(['hydration' => Resultset::HYDRATE_RECORDS]);
$model->url = '/';
$model->save();
Work's even with hydrate.
Just a info, The Model extends an AbstractModel
The Abstract Model has the proprerties
And the public get-set
Just a info, The Model extends an AbstractModel
Like this?
class AbstractModel extends \Phalcon\Mvc\Model
{
protected $prop;
public function getProp()
{
return $this->prop;
}
public function setProp($prop)
{
$this->prop = $prop;
return $this;
}
}
class MyModel extends AbstractModel {
}
$model = MyModel::findFirst();
$model->prop = 'secret';
$model->save();
Yes exactly .
works on both way $model->prop or $model->setProp()
Will write some extra tests for this to see if we can reproduce this. Are you on Linux?
Will write some extra tests for this to see if we can reproduce this. Are you on Linux?
Vagrant 2.2.6 VirtualBox 6.0.14 Ubuntu 19.10
Host Windows 10.
Zephir issue has been fixed in #2078. I'll release new version ASAP
Zephir 0.12.18 released: https://github.com/phalcon/zephir/releases/tag/0.12.18