如何将hasAttribute
与自定义域一起使用?
编码:
if ($model->hasAttribute($attribute)) {
...
} else {
$this->_sendResponse(400, 'Parameter \''.$attribute.'\' is not supported.');
}
实施例
Model.php
class Model extends CActiveRecord
{
public $customField;
...
编码:
$model = new Model;
$model->hasAttribute('customField'); // Returns False.
1条答案
按热度按时间pbpqsu0x1#
您只需用途:
https://www.php.net/manual/en/function.property-exists.php
hasAttribute
将只检查db属性。