在cakePHP中从对象检索属性

在cakePHP中从对象检索属性,php,cakephp-3.0,Php,Cakephp 3.0,我对PHP非常陌生,如果这是一个非常愚蠢的问题,我很抱歉 我正在使用cakePHP,在/src/Controller/CommentsController.php中的方法中包含以下代码: 调试$comment时,我会得到如下结果: object(App\Model\Entity\Comment) { 'new' => false, 'accessible' => [ 'user_id' => true, 'commentary'

我对PHP非常陌生,如果这是一个非常愚蠢的问题,我很抱歉

我正在使用cakePHP,在/src/Controller/CommentsController.php中的方法中包含以下代码:

调试$comment时,我会得到如下结果:

object(App\Model\Entity\Comment) {
    'new' => false,
    'accessible' => [
        'user_id' => true,
        'commentary' => true,
        'user' => true
    ],
    'properties' => [
        'id' => (int) 3,
        'user_id' => (int) 2,
        'commentary' => 'Hello World!',
        'created' => object(Cake\I18n\Time) {
            'time' => '2014-12-02T18:53:52+0000',
            'timezone' => 'UTC',
            'fixedNowTime' => false
        },
        'updated' => null
    ],
    'dirty' => [],
    'original' => [],
    'virtual' => [],
    'errors' => [],
    'repository' => 'Comments'
}

我需要将“properties”中的“user_id”与另一个变量进行比较,但我不知道如何访问对象$comment的属性。我尝试了$comment->properties和$comment['properties'],但都返回null。如何访问这些属性?

这些属性本质上是由id标识的表记录的字段。您可以访问以下任何属性:$comment->user\u id.Omg。非常感谢你!但我不明白为什么:/
object(App\Model\Entity\Comment) {
    'new' => false,
    'accessible' => [
        'user_id' => true,
        'commentary' => true,
        'user' => true
    ],
    'properties' => [
        'id' => (int) 3,
        'user_id' => (int) 2,
        'commentary' => 'Hello World!',
        'created' => object(Cake\I18n\Time) {
            'time' => '2014-12-02T18:53:52+0000',
            'timezone' => 'UTC',
            'fixedNowTime' => false
        },
        'updated' => null
    ],
    'dirty' => [],
    'original' => [],
    'virtual' => [],
    'errors' => [],
    'repository' => 'Comments'
}