本文整理匯總了PHP中query::prettyJson方法的典型用法代碼示例。如果您正苦於以下問題:PHP query::prettyJson方法的具體用法?PHP query::prettyJson怎麽用?PHP query::prettyJson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類query
的用法示例。
在下文中一共展示了query::prettyJson方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: elastica_create_main
/**
* Creates a part of the elastica query class
*
* @return string Part of the elastica query class
*/
private function elastica_create_main($data, $keys)
{
$query = new query();
$output = "\t/**\n";
$output .= "\t * The main searching function\n";
$output .= "\t * @return resultset A Elastica Resultset Object\n";
$output .= "\t */\n";
$output .= "\tpublic function search()\n";
$output .= "\t{\n";
$json = json_encode($data);
foreach ($keys as $key) {
$parts = explode('|-|', $key);
if (substr($parts[0], -6) == '_array') {
$vals = explode('/-/', $parts[1]);
$replacepattern = array();
foreach ($vals as $val) {
if (substr($val, -1) != '$') {
$val .= '$';
}
$replacepattern[] = $parts[0] . '|-|' . $val;
}
$key = implode('","', $replacepattern);
$json = str_replace('["' . $key . '"]', "' . json_encode(\$this->" . str_replace('$', '', $parts[0]) . ") . '", $json);
} else {
$json = str_replace($key, "' . \$this->" . str_replace('$', '', $parts[0]) . " . '", $json);
}
}
$json = $query->prettyJson($json);
$output .= "\t\t\$json = '{$json}';\n\n";
$output .= "\t\t\$queryBuilder = new \\Elastica\\Query\\Builder(\$json);\n\n";
$output .= "\t\t\$queryBuilder = new \\Elastica\\Query(\$queryBuilder->toArray());\n\n";
$output .= "\t\t\$search = new \\Elastica\\Search(new \\Elastica\\Client());\n\n";
$output .= "\t\treturn \$search->search(\$queryBuilder);\n";
$output .= "\t}\n";
return $output;
}