We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Why Dynamic add a property of the model instance is protected

class Robot extends Model {}

$r = Robot::findFirst("id = '1'");
$r->count = array('a','b','c','d');

protected '_related' => 
        array (size=1)
          'count' => 
            array (size=4)

What's your question?


I want to need property:count, but it access protected

Phalcon models have magic getters and setters, so when you call

$Robot->count = ['a','b','c','d'];

You're actually calling


Even though it's protected, you can still set it.

Read through the documentation about related models - it might give you some insight.