本文整理匯總了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);
}