private static function getList($infos, $params) { $infos = StringOpt::cameltounline($infos['index']); $infos = explode('_', $infos); if (empty($infos[0]) || empty($infos[1])) { return false; } $index = $infos[0]; $type = $infos[1]; $url = 'http://localhost:9200/' . $index . '/' . $type . '/_search'; $ret = HttpCurl::get($url, json_encode($params[0])); $body = json_decode($ret['body'], true); if ($body == false || empty($body['hits']['total'])) { return false; } return $body; }
public static function __callStatic($method, $params) { // {{{ $pattern = '/^find(?<sth>(.*){0,1})From(?<table>.*)$/'; $method_infos = array(); if (preg_match($pattern, $method, $method_infos) == false) { echo 'ERROR: method error' . PHP_EOL; return false; } $table = StringOpt::cameltounline(lcfirst($method_infos['table'])); self::setTable($table); switch ($method_infos['sth']) { case '': case 'One': case 'Count': $func = 'find' . $method_infos['sth'] . 'By'; $params = empty($params) ? array('') : $params; return self::$func($params[0]); default: $field = StringOpt::cameltounline(lcfirst($method_infos['sth'])); return self::findOneByField($field, $params[0]); } }