本文整理汇总了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;
}