本文整理汇总了PHP中Phalcon\Mvc\Model::__set方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::__set方法的具体用法?PHP Model::__set怎么用?PHP Model::__set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\Model
的用法示例。
在下文中一共展示了Model::__set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
public function __set($fieldName, $value)
{
// Check if the property is public
try {
$R = new \ReflectionClass($this);
$property = $R->getProperty($fieldName);
} catch (\ReflectionException $e) {
// Property doesn't exist, call the stupid parent
return parent::__set($fieldName, $value);
}
if ($property->isPublic()) {
// Again, call your parents
return parent::__set($fieldName, $value);
} else {
// Property exists, and it's private / protected
try {
// Maybe there is a setter for this one?
$nameArr = explode('_', $fieldName);
$methodName = 'set';
foreach ($nameArr as $vv) {
$methodName .= ucwords($vv);
}
$method = $R->getMethod($methodName);
// Okay, no exception, let's call it
return $this->{$methodName}($value);
} catch (\ReflectionException $up) {
// Just let it go through
throw $up;
}
}
}
示例2: __set
public function __set($property, $value)
{
if (is_object($property) || is_array($property)) {
return parent::__set($property, $value);
}
$this->_dataAccess[$property] = $value;
}
示例3: __set
/**
* Magic method to use attribute in snake_case
* For example $ex->a_method = $value is same as $ex->setAMethod($value)
* @param string $property The property in snake_case
* @param array $params The value that will be passed to set method
* @return mixed Call the method if it exists, otherwise call parent __set() method
*/
public function __set($property, $params)
{
$method = 'set' . Phalcon\Text::camelize($property);
if (method_exists($this, $method)) {
return $this->{$method}($params);
}
parent::__set($property, $params);
}