Created
May 29, 2016 22:40
-
-
Save o-shabashov/9befcc233f2a989a787f5b3b689750b9 to your computer and use it in GitHub Desktop.
Yii2 ActiveRecord->hasAttribute VS Model->hasProperty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// class ContactForm extends Model | |
$contact = new ContactForm(); | |
// class User extends \yii\db\ActiveRecord | |
$user = new User(); | |
isset($contact->email); // false | |
$contact->hasProperty('email'); // true | |
isset($user->email); // false | |
$user->hasProperty('email'); // false | |
$user->hasAttribute('email'); // true | |
$contact->email = 'test'; | |
$user->email = 'test'; | |
isset($contact->email); // true | |
$contact->hasProperty('email'); // true | |
isset($user->email); // true | |
$user->hasProperty('email'); // false | |
$user->hasAttribute('email'); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment