本文整理汇总了PHP中Finder::getMethodSignature方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::getMethodSignature方法的具体用法?PHP Finder::getMethodSignature怎么用?PHP Finder::getMethodSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Finder
的用法示例。
在下文中一共展示了Finder::getMethodSignature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateFinder
private function generateFinder(Finder $finder, Entity $entity)
{
$orderByClause = $finder->hasOrder() ? $finder->getOrderByClause() : $entity->getOrderByClause();
$result = "\tpublic function {$finder->getMethodSignature()} {\n" . "\t\t\$limitStr = (\$from == -1 && \$limit == -1) ? \"\" : \" LIMIT \$from,\$limit\";\n" . "\t\t\$whereClause = \"" . implode(" AND ", $finder->getWhereClauses()) . $orderByClause . "\".\$limitStr;\n";
if ($finder->isCacheable()) {
$result .= "\t\tif(parent::\$dbCache->hasFinder('{$entity->getName()}', \$whereClause)) {\n" . "\t\t\treturn parent::\$dbCache->getFinder('{$entity->getName()}', \$whereClause);\n" . "\t\t}\n";
}
$result .= "\t\t\$result = \$this->db->selectQuery(\"SELECT * FROM \".self::TABLE.\" WHERE \$whereClause\");\n";
if ($finder->isUnique()) {
$result .= "\t\tif(\$result->isEmpty()) {\n" . "\t\t\tthrow new NoSuch{$entity->getName()}Exception();\n" . "\t\t}\n" . "\t\t\$result = \$this->getAsObject(\$result->getSingleRow());\n";
} else {
$result .= "\t\t\$result = \$this->getAsObjects(\$result->getResult());\n";
}
if ($finder->isCacheable()) {
$result .= "\t\tparent::\$dbCache->setFinder('{$entity->getName()}', \$whereClause, \$result);\n";
}
return $result . "\t\treturn \$result;\n\t}\n\n";
}