本文整理汇总了PHP中CActiveRecord::__call方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::__call方法的具体用法?PHP CActiveRecord::__call怎么用?PHP CActiveRecord::__call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecord
的用法示例。
在下文中一共展示了CActiveRecord::__call方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
public function __call($name, $arguments)
{
$flags = $this->cachedFlags();
if (isset($flags[strtolower($name)])) {
return $this->withFlag($name);
}
return parent::__call($name, $arguments);
}
示例2: __call
public function __call($name, $args)
{
$this->initRelation();
if (isset($this->__relations[$name])) {
if (is_numeric($args[0])) {
$this->__page[$name] = $args[0];
if (count($args) == 2 && is_numeric($args[1])) {
$this->__pageSize[$name] = $args[1];
}
$criteria = $this->relPagingCriteria($name);
} else {
if (is_array($args[0])) {
$opt = $args[0];
$setRelPaging = false;
if (isset($opt['page'])) {
$this->__page[$name] = $opt['page'];
unset($opt['page']);
$setRelPaging = true;
}
if (isset($opt['pageSize'])) {
$this->__pageSize[$name] = $opt['pageSize'];
unset($opt['pageSize']);
}
if ($setRelPaging) {
$criteria = $this->relPagingCriteria($name);
$criteria = array_merge($criteria, $opt);
} else {
$criteria = $opt;
}
}
}
$this->loadRelation($name, @$criteria);
$this->applyRelChange($name);
return $this->__relations[$name];
} else {
return parent::__call($name, $args);
}
}
示例3: __call
/**
* Added an override to __call to create the addRELATION() and removeRELATION() methods
* PHP setter magic method.
* @param string $name property name
* @param mixed $value property value
*/
public function __call($name, $parameters)
{
if (strpos($name, 'add') === 0) {
$relation = lcfirst(substr($name, 3));
if ($this->getManyManyRelation($relation)) {
if (!empty($parameters)) {
return $this->addRelated($relation, $parameters[0]);
} elseif (count($parameters) > 1) {
throw new CException('Too many parameters.');
} else {
throw new CException('You must pass in a related model to add.');
}
}
}
if (strpos($name, 'remove') === 0) {
$relation = lcfirst(substr($name, 6));
if ($this->getManyManyRelation($relation)) {
if (!empty($parameters)) {
return $this->removeRelated($relation, $parameters[0]);
} elseif (count($parameters) > 1) {
throw new CException('Too many parameters.');
} else {
throw new CException('You must pass in a related model to add.');
}
}
}
return parent::__call($name, $parameters);
}