本文整理汇总了PHP中fORM::getRecordSetMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP fORM::getRecordSetMethod方法的具体用法?PHP fORM::getRecordSetMethod怎么用?PHP fORM::getRecordSetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fORM
的用法示例。
在下文中一共展示了fORM::getRecordSetMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
/**
* Allows for preloading various data related to the record set in single database queries, as opposed to one query per record
*
* This method will handle methods in the format `verbRelatedRecords()` for
* the verbs `build`, `prebuild`, `precount` and `precreate`.
*
* `build` calls `create{RelatedClass}()` on each record in the set and
* returns the result as a new record set. The relationship route can be
* passed as an optional parameter.
*
* `prebuild` builds *-to-many record sets for all records in the record
* set. `precount` will count records in *-to-many record sets for every
* record in the record set. `precreate` will create a *-to-one record
* for every record in the record set.
*
* @param string $method_name The name of the method called
* @param string $parameters The parameters passed
* @return void
*/
public function __call($method_name, $parameters)
{
if ($callback = fORM::getRecordSetMethod($method_name)) {
return call_user_func_array($callback, array($this, $this->class, &$this->records, $method_name, $parameters));
}
list($action, $subject) = fORM::parseMethod($method_name);
$route = $parameters ? $parameters[0] : NULL;
// This check prevents fGrammar exceptions being thrown when an unknown method is called
if (in_array($action, array('build', 'prebuild', 'precount', 'precreate'))) {
$related_class = fGrammar::singularize($subject);
$related_class_sans_namespace = $related_class;
if (!is_array($this->class)) {
$related_class = fORM::getRelatedClass($this->class, $related_class);
}
}
switch ($action) {
case 'build':
if ($route) {
$this->precreate($related_class, $route);
return $this->buildFromCall('create' . $related_class_sans_namespace, $route);
}
$this->precreate($related_class);
return $this->buildFromCall('create' . $related_class_sans_namespace);
case 'prebuild':
return $this->prebuild($related_class, $route);
case 'precount':
return $this->precount($related_class, $route);
case 'precreate':
return $this->precreate($related_class, $route);
}
throw new fProgrammerException('Unknown method, %s(), called', $method_name);
}