本文整理汇总了PHP中CModel::__call方法的典型用法代码示例。如果您正苦于以下问题:PHP CModel::__call方法的具体用法?PHP CModel::__call怎么用?PHP CModel::__call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModel
的用法示例。
在下文中一共展示了CModel::__call方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Magic __call() method, used for chain-setting attribute values.
*
* @param string $name
* @param array $arguments
* @return BaseModel
*/
function __call($name, $arguments)
{
if (in_array($name, $this->attributeNames())) {
if (count($arguments) == 1) {
$this->setAttribute($name, $arguments[0]);
} else {
$this->setAttribute($name, $arguments);
}
return $this;
} else {
return parent::__call($name, $arguments);
}
}
示例2: __call
public function __call($name, $parameters)
{
if (isset($this->getMetaData()->relations[$name])) {
if (empty($parameters)) {
return $this->getRelated($name, false);
} else {
return $this->getRelated($name, false, $parameters[0]);
}
}
$scopes = $this->scopes();
if (isset($scopes[$name])) {
$this->getDbCriteria()->mergeWith($scopes[$name]);
return $this;
}
return parent::__call($name, $parameters);
}
示例3: __call
/**
* @see CComponent::__call()
* @param string $name
* @param array $parameters
* @return mixed
*/
public function __call($name, $parameters)
{
if (!array_key_exists($name, $this->relations())) {
return parent::__call($name, $parameters);
}
if (empty($parameters)) {
return $this->getRelated($name, false);
}
return $this->getRelated($name, false, $parameters[0]);
}
示例4: __call
/**
* Magic __call() method, used for chain-setting attribute values.
*
* @param string $name
* @param array $arguments
*
* @return BaseModel
*/
public function __call($name, $arguments)
{
try {
return parent::__call($name, $arguments);
} catch (\CException $e) {
// Is this one of our attributes?
if (!$this->strictAttributes || in_array($name, $this->attributeNames())) {
$copy = $this->copy();
if (count($arguments) == 1) {
$copy->setAttribute($name, $arguments[0]);
} else {
$copy->setAttribute($name, $arguments);
}
return $copy;
}
throw $e;
}
}
示例5: __call
/**
* Calls the named method which is not a class method.
* Do not call this method. This is a PHP magic method that we override
* to implement the named scope feature.
* @param string $name the method name
* @param array $parameters method parameters
* @return mixed the method return value
*/
public function __call($name, $parameters)
{
if (isset($this->_links[$name])) {
if (empty($parameters)) {
return $this->getLinked($name, false);
} else {
return $this->getLinked($name, false, $parameters[0]);
}
}
$scopes = $this->scopes();
if (isset($scopes[$name])) {
$this->getCriteria()->mergeWith($scopes[$name]);
return $this;
}
return parent::__call($name, $parameters);
}