Showing preview only (735K chars total). Download the full file or copy to clipboard to get everything.
Repository: qieangel2013/EsParser
Branch: master
Commit: 3beffb3e3219
Files: 124
Total size: 692.1 KB
Directory structure:
gitextract_02kj_sub/
├── EsParser_realse.php
├── README.md
├── composer.json
├── index.php
└── src/
├── example.php
└── library/
├── EsCreator.php
├── EsParser.php
├── builders/
│ ├── AliasBuilder.php
│ ├── CharacterSetBuilder.php
│ ├── CheckBuilder.php
│ ├── CollationBuilder.php
│ ├── ColumnDefinitionBuilder.php
│ ├── ColumnListBuilder.php
│ ├── ColumnReferenceBuilder.php
│ ├── ColumnTypeBracketExpressionBuilder.php
│ ├── ColumnTypeBuilder.php
│ ├── ConstantBuilder.php
│ ├── ConstraintBuilder.php
│ ├── CreateBuilder.php
│ ├── CreateStatementBuilder.php
│ ├── CreateTableBuilder.php
│ ├── CreateTableDefinitionBuilder.php
│ ├── CreateTableOptionsBuilder.php
│ ├── CreateTableSelectOptionBuilder.php
│ ├── DataTypeBuilder.php
│ ├── DatabaseBuilder.php
│ ├── DeleteBuilder.php
│ ├── DeleteStatementBuilder.php
│ ├── DirectionBuilder.php
│ ├── EngineBuilder.php
│ ├── ForeignKeyBuilder.php
│ ├── ForeignRefBuilder.php
│ ├── FromBuilder.php
│ ├── FunctionBuilder.php
│ ├── GroupByBuilder.php
│ ├── InListBuilder.php
│ ├── IndexColumnBuilder.php
│ ├── IndexParserBuilder.php
│ ├── IndexSizeBuilder.php
│ ├── IndexTypeBuilder.php
│ ├── InsertBuilder.php
│ ├── InsertStatementBuilder.php
│ ├── JoinBuilder.php
│ ├── LikeBuilder.php
│ ├── LikeExpressionBuilder.php
│ ├── LimitBuilder.php
│ ├── OperatorBuilder.php
│ ├── OrderByAliasBuilder.php
│ ├── OrderByBuilder.php
│ ├── PositionBuilder.php
│ ├── PrimaryKeyBuilder.php
│ ├── ProcedureBuilder.php
│ ├── RecordBuilder.php
│ ├── RefClauseBuilder.php
│ ├── RefTypeBuilder.php
│ ├── ReservedBuilder.php
│ ├── SelectBracketExpressionBuilder.php
│ ├── SelectBuilder.php
│ ├── SelectExpressionBuilder.php
│ ├── SelectStatementBuilder.php
│ ├── SetBuilder.php
│ ├── SetExpressionBuilder.php
│ ├── ShowBuilder.php
│ ├── ShowStatementBuilder.php
│ ├── SubQueryBuilder.php
│ ├── SubTreeBuilder.php
│ ├── TableBracketExpressionBuilder.php
│ ├── TableBuilder.php
│ ├── TableExpressionBuilder.php
│ ├── UpdateBuilder.php
│ ├── UpdateStatementBuilder.php
│ ├── UserVariableBuilder.php
│ ├── ValuesBuilder.php
│ ├── WhereBracketExpressionBuilder.php
│ ├── WhereBuilder.php
│ └── WhereExpressionBuilder.php
├── exceptions/
│ ├── InvalidParameterException.php
│ ├── UnableToCalculatePositionException.php
│ ├── UnableToCreateSQLException.php
│ └── UnsupportedFeatureException.php
├── lexer/
│ ├── LexerSplitter.php
│ └── PHPSQLLexer.php
├── positions/
│ └── PositionCalculator.php
├── processors/
│ ├── AbstractProcessor.php
│ ├── ColumnDefinitionProcessor.php
│ ├── ColumnListProcessor.php
│ ├── CreateDefinitionProcessor.php
│ ├── CreateProcessor.php
│ ├── DefaultProcessor.php
│ ├── DeleteProcessor.php
│ ├── DescProcessor.php
│ ├── DescribeProcessor.php
│ ├── DropProcessor.php
│ ├── DuplicateProcessor.php
│ ├── ExplainProcessor.php
│ ├── ExpressionListProcessor.php
│ ├── FromProcessor.php
│ ├── GroupByProcessor.php
│ ├── HavingProcessor.php
│ ├── IndexColumnListProcessor.php
│ ├── InsertProcessor.php
│ ├── IntoProcessor.php
│ ├── LimitProcessor.php
│ ├── OrderByProcessor.php
│ ├── RecordProcessor.php
│ ├── ReferenceDefinitionProcessor.php
│ ├── RenameProcessor.php
│ ├── ReplaceProcessor.php
│ ├── SQLChunkProcessor.php
│ ├── SQLProcessor.php
│ ├── SelectExpressionProcessor.php
│ ├── SelectProcessor.php
│ ├── SetProcessor.php
│ ├── ShowProcessor.php
│ ├── TableProcessor.php
│ ├── UnionProcessor.php
│ ├── UpdateProcessor.php
│ ├── UsingProcessor.php
│ ├── ValuesProcessor.php
│ └── WhereProcessor.php
└── utils/
├── ExpressionToken.php
├── ExpressionType.php
├── PHPSQLParserConstants.php
└── PHPSQLParserUtils.php
================================================
FILE CONTENTS
================================================
================================================
FILE: EsParser_realse.php
================================================
<?php
/*
|---------------------------------------------------------------
| Copyright (c) 2018
|---------------------------------------------------------------
| 作者:qieangel2013
| 联系:qieangel2013@gmail.com
| 版本:V1.0
| 日期:2018/3/13
|---------------------------------------------------------------
*/
require_once dirname(__FILE__) . '/positions/PositionCalculator.php';
require_once dirname(__FILE__) . '/processors/DefaultProcessor.php';
class EsParser {
public $parsed;
private $Builderarr;
public $url;
private $top_hits=0;
private $top_hits_size=1;
private $agg;
private $sort;
private $index_es='';
private $type_es='';
private $version_es='';
private $count_tmp=0;
private $count_tmp_filter=0;
private $count_tmp_range=0;
private $count_fi=0;
private $tmp_str='';
private $tmp_str_filter='';
private $tmp_fi='';
private $tmp_str_range='';
private $tmp_lock='';
private $tmp_lock_str='';
private $tmp_lock_fi='';
private $tmp_lock_range='';
private $fistgroup='';
private $limit;
public $result;
public $explain;
/**
* Constructor. It simply calls the parse() function.
* Use the public variable $parsed to get the output.
*
* @param String $sql The SQL statement.
* @param boolean $calcPositions True, if the output should contain [position], false otherwise.
*/
public function __construct($sql = false,$calcPositions = false,$es_config=array()) {
if(empty($es_config)){
$config_err=array(
'fail' =>1,
'message'=>'es的配置项不能为空!'
);
$this->result=json_encode($config_err,true);
return $this->result;
}else{
$this->index_es=$es_config['index'];
$this->type_es=$es_config['type'];
$this->url=$es_config['url'];
if(!isset($es_config['version'])){
$version=$this->getEsData($es_config['url']);
if($version){
if(version_compare($version,'5.0.0', '<')){
$this->version_es='2.x';
}else if( version_compare($version,'5.0.0', '>=') && version_compare($version,'6.0.0', '<')){
$this->version_es='5.x';
}else{
$this->version_es='6.x';
}
}else{
$this->version_es='5.x';
}
}else{
if(trim($es_config['version'])==''){
$this->version_es='5.x';
}else{
$this->version_es=$es_config['version'];
}
}
}
if ($sql) {
$this->parse($sql, $calcPositions);
}
}
/**
*
* @param String $sql The SQL statement.
* @param boolean $calcPositions True, if the output should contain [position], false otherwise.
*
* @return array An associative array with all meta information about the SQL statement.
*/
public function parsesql($sql, $calcPositions = false) {
$processor = new DefaultProcessor();
$queries = $processor->process($sql);
if ($calcPositions) {
$calculator = new PositionCalculator();
$queries = $calculator->setPositionsWithinSQL($sql, $queries);
}
$this->parsed = $queries;
return $this->parsed;
}
public function parse($sql, $calcPositions = false) {
$processor = new DefaultProcessor();
$queries = $processor->process($sql);
if ($calcPositions) {
$calculator = new PositionCalculator();
$queries = $calculator->setPositionsWithinSQL($sql, $queries);
}
$this->parsed = $queries;
return $this->EsBuilder();
//return $this->parsed;
}
private function EsBuilder(){
//table
if(isset($this->parsed['FROM']) && !empty($this->parsed['FROM'])){
$this->table($this->parsed['FROM']);
}
//update
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->update($this->parsed['UPDATE']);
}
//set
if(isset($this->parsed['SET']) && !empty($this->parsed['SET'])){
$this->updateset($this->parsed['SET']);
}
//delete
if(isset($this->parsed['DELETE']) && !empty($this->parsed['DELETE'])){
$this->delete($this->parsed['DELETE']);
}
//limit
if(isset($this->parsed['LIMIT']) && !empty($this->parsed['LIMIT'])){
$this->limit($this->parsed['LIMIT']);
if(isset($this->parsed['GROUP']) && !empty($this->parsed['GROUP'])){
$this->Builderarr['size']=0;
}else{
$this->Builderarr['from']=$this->limit['from'] * $this->limit['size'];
$this->Builderarr['size']=$this->limit['size'];
}
}
//where
if(isset($this->parsed['WHERE']) && !empty($this->parsed['WHERE'])){
$this->where($this->parsed['WHERE']);
}
//groupby
if(isset($this->parsed['GROUP']) && !empty($this->parsed['GROUP'])){
$this->groupby($this->parsed['GROUP']);
if(!empty($this->agg['aggs'])){
$this->Builderarr['aggs']=$this->agg['aggs'];
}
}
//orderby
if(isset($this->parsed['ORDER']) && !empty($this->parsed['ORDER'])){
$this->orderby($this->parsed['ORDER']);
if(!empty($this->sort['sort'])){
$this->Builderarr['sort']=$this->sort['sort'];
}
}
//select
if(isset($this->parsed['SELECT']) && !empty($this->parsed['SELECT'])){
$this->select($this->parsed['SELECT']);
}
if(!isset($this->Builderarr) && empty($this->Builderarr)){
$this->Builderarr['query']['match_all']=(object)array();
}
//request
return $this->PostEs($this->Builderarr);
}
public function explain(){
$this->explain=json_encode($this->Builderarr,true);
return $this->explain;
}
private function table($arr){
if(isset($this->parsed['DELETE']) && !empty($this->parsed['DELETE'])){
foreach ($arr as $v) {
if($v['table']){
$this->url .="/".$this->index_es."/".$this->type_es."/_delete_by_query?pretty";
}
}
}else{
foreach ($arr as $v) {
if($v['table']){
$this->url .="/".$this->index_es."/".$this->type_es."/_search?pretty";
}
}
}
}
private function update($arr){
foreach ($arr as $v) {
if($v['table']){
$this->table=$v['table'];
$this->url .="/".$this->index_es."/".$this->type_es."/";
}
}
}
private function delete($arr){
}
private function getEsData($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ;
$output = curl_exec($ch);
if($output === false) //超时处理
{
if(curl_errno($ch) == CURLE_OPERATION_TIMEDOUT)
{
my_file_put_contents("getEsData.txt", "时间:".date('Ymd-H:i:s',time())."\r\n错误内容为:curl通过get方式请求{$url}的连接超时\r\n");
}
}
curl_close($ch);
$output=json_decode($output,true);
if (empty($output)) {
return array();
}
return $output['version']['number'];
}
private function PostEs($postdata,$json=true,$token=false){
$url=$this->url;
$datastring = json_encode($postdata,true);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url) ;
curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60); //只需要设置一个秒的数量就可以
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datastring);
if ($json) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json;',
'Content-Length: ' . strlen($datastring))
);
}
if ($token) {
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($datastring),
'Authorization:'.$token
)
);
}
$output=curl_exec($ch);
if($output === false) //超时处理
{
if(curl_errno($ch) == CURLE_OPERATION_TIMEDOUT)
{
file_put_contents("getEsData.txt", "时间:".date('Ymd-H:i:s',time())."\r\n错误内容为:curl通过post方式请求{$this->url}的连接超时\r\n");
}
}
curl_close($ch);
$output=json_decode($output,true);
if (empty($output)) {
$this->result=json_encode(array(),true);
}
if(isset($output['error'])){
$this->result=json_encode($output,true);
}else if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$update_arr=$output['_shards'];
unset($update_arr['total']);
$this->result=json_encode($update_arr,true);
}else if(isset($this->parsed['DELETE']) && !empty($this->parsed['DELETE'])){
$delete_arr['total']=$output['total'];
$delete_arr['deleted']=$output['deleted'];
$delete_arr['successfull']=$output['deleted'];
$this->result=json_encode($delete_arr,true);
}else{
$total_str=$output['hits']['total'];
if(isset($this->parsed['GROUP']) && !empty($this->parsed['GROUP'])){
if($output['hits']['hits'] && empty($output['aggregations'][$this->fistgroup]['buckets'])){
$outputs['result']=array_slice($output['hits']['hits'],-$this->limit['size']);
}else if(isset($output['aggregations'][$this->fistgroup]['buckets']) && !empty($output['aggregations'][$this->fistgroup]['buckets'])){
$outputs['result']=$output['aggregations'][$this->fistgroup]['buckets'];
}else{
$outputs['result']=array_slice($output['aggregations'][$this->fistgroup]['buckets'],-$this->limit['size']);
}
}else{
if(isset($output['aggregations']) && !empty($output['aggregations'])){
$outputs['result']=$output['aggregations'];
}else{
$outputs['result']=$output['hits']['hits'];
}
}
$outputs['total']=$total_str;
$this->result=json_encode($outputs,true);
}
return $this->result;
}
private function where($arr){
for($i=0;$i<count($arr);$i++){
if($arr[$i]['expr_type']=='bracket_expression'){
if($arr[$i]['sub_tree']){
for($j=0;$j<count($arr[$i]['sub_tree']);$j++){
$this->whereext($arr[$i]['sub_tree'],$j);
}
}
}else{
$this->whereext($arr,$i);
}
}
}
private function whereext($arr,$i){
if(!is_numeric($arr[$i]['base_expr'])){
$lowerstr = strtolower($arr[$i]['base_expr']);
}else{
$lowerstr = $arr[$i]['base_expr'];
}
switch ($lowerstr) {
case '=':
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][0]['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_tmp]['bool']['should'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_tmp]['bool']['should'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock=$lowerstr;
$this->tmp_lock_str=$lowerstr;
}else if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='and' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='and'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['bool']['must'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['bool']['must'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock_str=$lowerstr;
}
break;
case 'in':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($arr[$i+1]['sub_tree']) && !empty($arr[$i+1]['sub_tree'])){
foreach ($arr[$i+1]['sub_tree'] as &$vv) {
if(!is_numeric($vv['base_expr']) && $this->version_es=='5.x'){
$termk .='.keyword';
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['terms'][$termk][]=$vv['base_expr'];
}
}
unset($termk);
$this->tmp_lock=$lowerstr;
break;
case '>':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi==$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][0]) && $this->tmp_lock_range!=''){
if($this->tmp_str_range==''){
$this->count_tmp_range++;
}else if($this->tmp_str_range!='' && $this->tmp_str_range!=$termk){
$this->count_tmp_range++;
}
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['gt']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']="+08:00";
}
}else{
if(isset($this->Builderarr['query']['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['gt']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']="+08:00";
}
}
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_range=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case '>=':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi==$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][0]) && $this->tmp_lock_range!='' ){
if($this->tmp_str_range==''){
$this->count_tmp_range++;
}else if($this->tmp_str_range!='' && $this->tmp_str_range!=$termk){
$this->count_tmp_range++;
}
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['gte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']="+08:00";
}
}else{
if(isset($this->Builderarr['query']['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['gte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']="+08:00";
}
}
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_range=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case '<':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi==$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][0]) && $this->tmp_lock_range!=''){
if($this->tmp_str_range==''){
$this->count_tmp_range++;
}else if($this->tmp_str_range!='' && $this->tmp_str_range!=$termk){
$this->count_tmp_range++;
}
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['lt']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']="+08:00";
}
}else{
if(isset($this->Builderarr['query']['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['lt']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']="+08:00";
}
}
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_range=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case '<=':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi==$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][0]) && $this->tmp_lock_range!='' ){
if($this->tmp_str_range==''){
$this->count_tmp_range++;
}else if($this->tmp_str_range!='' && $this->tmp_str_range!=$termk){
$this->count_tmp_range++;
}
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['lte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']="+08:00";
}
}else{
if(isset($this->Builderarr['query']['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['lte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']="+08:00";
}
}
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_range=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case 'like':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_la_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_la_str=str_replace("'","",$tmp_la_str);
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi!=$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match'][$termk.'.keyword']=str_replace("%","",$tmp_la_str);
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][]=$term;
}else{
$term['match'][$termk]=str_replace("%","",$tmp_la_str);
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][]=$term;
}
}else{
if(isset($this->Builderarr['query']['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match'][$termk.'.keyword']=str_replace("%","",$tmp_la_str);
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['bool']['must'][]=$term;
}else{
$term['match'][$termk]=str_replace("%","",$tmp_la_str);
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['bool']['must'][]=$term;
}
}
unset($term['match']);
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case 'between':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
if(isset($this->Builderarr['query']['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['gte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['time_zone']="+08:00";
}
$tmp_da_str=str_replace('"','',$arr[$i+3]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$this->Builderarr['query']['bool']['must'][$this->count_tmp]['range'][$termk]['lte']=$tmp_da_str;
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
break;
}
}
private function listtree($arr,$aggs,$order){
$countmp=0;
for($i=count($arr)-1;$i>=0;$i--){
if(isset($arr[$i-1])){
$key_arr=array_keys($arr[$i]);
if($countmp==0){
$arr[$i][$key_arr[0]]['terms']['size']=$this->limit['from']*$this->limit['size']==0?10:($this->limit['from'] + 1 )*$this->limit['size'];
if($aggs['aggs']){
$arr[$i][$key_arr[0]]['aggs']=$aggs['aggs'];
}
if($order){
$arr[$i][$key_arr[0]]['terms']['order']=$order['order'];
}
$arr[$i][$key_arr[0]]['aggs']['top']['top_hits']['size']=$this->top_hits;
$countmp=1;
}
$key_pre=array_keys($arr[$i-1]);
$arr[$i-1][$key_pre[0]]['aggs']=$arr[$i];
unset($arr[$i]);
}else{
if(count($arr)==1 && $countmp==0){
$key_arrs=array_keys($arr[$i]);
$arr[$i][$key_arrs[0]]['terms']['size']=$this->limit['from']*$this->limit['size']==0?10:($this->limit['from'] + 1 )*$this->limit['size'];
$arr[$i][$key_arrs[0]]['aggs']['top']['top_hits']['size']=$this->top_hits;
$countmp=1;
}
}
}
return $arr;
}
private function groupby($arr){
$aggs= array();
$agg= array();
$agg_orderby=array();
for($i=0; $i <count($arr); $i++) {
if(strrpos($arr[$i]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
$termk_tmp=$termk;
}else{
$termk=$arr[$i]['base_expr'];
$termk_tmp=$term_tmp_arr[0];
}
}else{
$termk=$arr[$i]['base_expr'];
$termk_tmp=$termk;
}
if(isset($this->fistgroup) && $this->fistgroup==''){
$this->fistgroup=$termk_tmp.'_group';
}
$agg[$i][$termk_tmp.'_group']['terms']['field']=$termk;
}
if(isset($this->parsed['SELECT']) && !empty($this->parsed['SELECT'])){
foreach ($this->parsed['SELECT'] as $v) {
$this->top_hits=1;
if(strrpos($v['base_expr'],"*")){
//$this->top_hits=1;
}else{
if($v['expr_type']=='aggregate_function'){
$lowerstr = strtolower($v['base_expr']);
switch ($lowerstr) {
case 'count':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
$cardinalitys[$v['alias']['name']]['cardinality']['field']=$term_tmp_arrs[1];
}else{
$cardinalitys[$v['alias']['name']]['cardinality']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
case 'sum':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
$cardinalitys[$v['alias']['name']]['sum']['field']=$term_tmp_arrs[1];
}else{
$cardinalitys[$v['alias']['name']]['sum']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
case 'min':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
$cardinalitys[$v['alias']['name']]['min']['field']=$term_tmp_arrs[1];
}else{
$cardinalitys[$v['alias']['name']]['min']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
case 'max':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
$cardinalitys[$v['alias']['name']]['max']['field']=$term_tmp_arrs[1];
}else{
$cardinalitys[$v['alias']['name']]['max']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
case 'avg':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
$cardinalitys[$v['alias']['name']]['avg']['field']=$term_tmp_arrs[1];
}else{
$cardinalitys[$v['alias']['name']]['avg']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
}
if(isset($this->parsed['ORDER']) && !empty($this->parsed['ORDER'])){
foreach ($this->parsed['ORDER'] as $vv) {
if($vv['base_expr']==$v['alias']['name']){
$agg_orderby['order'][$vv['base_expr']]=$vv['direction'];
}
}
}
}
}
}
if($tmmp==0){
$agg[$j][$termk_tmp.'_group']['terms']['field']=$termk;
$agg[$j][$termk_tmp.'_group']['terms']['size']=$this->limit['from']*$this->limit['size']==0?10:($this->limit['from'] + 1 )*$this->limit['size'];
$agggs[$j][$termk_tmp.'_group']['aggs']=(object)array();
$aggs[$j]=array_merge_recursive($agg[$j], $agggs[$j]);
unset($aggs[$j][$termk_tmp.'_group']['aggs']);
}
}
$this->agg['aggs']=$this->listtree($agg,$aggs,$agg_orderby)[0];
}
private function orderby($arr){
if(isset($this->parsed['SELECT']) && !empty($this->parsed['SELECT'])){
foreach ($this->parsed['SELECT'] as $v) {
foreach ($arr as $kk=>$vv) {
if($v['alias']){
if($v['alias']['name']==$vv['base_expr']){
unset($arr[$kk]);
}
}
}
}
}
foreach ($arr as &$va) {
if(strrpos($va['base_expr'],".")){
$term_tmp_arr=explode(".",$va['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$va['base_expr'];
}
$this->sort['sort'][][$termk]['order']=$va['direction'];
}
}
private function limit($arr){
if(!$arr['offset']){
$this->limit['from']=0;
}else{
$this->limit['from']=$arr['offset'];
}
$this->limit['size']=$arr['rowcount'];
}
private function select($arr){
if(isset($this->parsed['GROUP']) && !empty($this->parsed['GROUP'])){
}else{
foreach ($arr as $k => $v) {
if($v['expr_type']=='aggregate_function'){
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
if($term_tmp_arrs[1]=='*'){
continue;
}
if(isset($v['alias']['name'])){
$this->Builderarr['aggs'][$v['alias']['name']]['stats']['field']=$term_tmp_arrs[1];
}else{
$this->Builderarr['aggs'][$v['sub_tree'][0]['base_expr']]['stats']['field']=$term_tmp_arrs[1];
}
}else{
if($v['sub_tree'][0]['base_expr']=='*'){
continue;
}
if(isset($v['alias']['name'])){
$this->Builderarr['aggs'][$v['alias']['name']]['stats']['field']=$v['sub_tree'][0]['base_expr'];
}else{
$this->Builderarr['aggs'][$v['sub_tree'][0]['base_expr']]['stats']['field']=$v['sub_tree'][0]['base_expr'];
}
}
}
}
}
}
private function updateset($arr){
foreach ($arr as &$v) {
if($v['sub_tree']){
$tmp_sub[$v['sub_tree'][0]['base_expr']]=$v['sub_tree'][2]['base_expr'];
$this->Builderarr['doc']=$tmp_sub;
unset($tmp_sub);
}
}
}
}
?>
================================================
FILE: README.md
================================================
# EsParser
php的操作类库,通过写sql来转化dsl来查询elasticsearch
### composer使用
{
"require": {
"qieangel2013/esparser": "dev-master"
}
}
composer install
require __DIR__.'/vendor/autoload.php';
//$sql = 'select * from alp_dish_sales_saas where sid in(994,290) limit 1,10';
//$sql='update alp_dish_sales_saas set mid=3 where adsid=15125110';
//$sql='delete from alp_dish_sales_saas where adsid=15546509';
//$sql="select *,concat_ws('_',category_name.keyword,dish_name.keyword,sku_name.keyword) as dfg from alp_dish_sales_saas where sale_date>'2017-01-01' and sale_date<'2017-09-02' group by dfg order by total_count desc";
//$sql = 'select *,DATE_FORMAT(sale_date,"%Y-%m-%d") as days from alp_dish_sales_saas group by days ';
$sql="insert into test(`id`,`name`)values(9,'zz')";
$sql2="insert into test(`id`,`name`)values(9,'zz')";
$es_config=array(
'index' =>"alp_dish_sales_saas",
'type' =>"alp_dish_sales_saas",
'url' =>"http://127.0.0.1:9200",
'version' =>"5.x" //1.x 2.x 5.x 6.x 7.x,可以不配置,系统会请求获取版本,这样会多一次请求,建议配置一下
);
$parser = new EsParser($sql, true,$es_config);//第三个参数是es的配置参数,一定要配置
print_r($parser->build());//打印结果
print_r($parser->setSql($sql2)->build());//打印结果
$result=$parser->scroll();//深度分页初始化会返回第一条
$result=json_decode($result,true);
print_r($result);//打印深度分页结果
$result1=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result1,true));//打印深度分页结果
$result2=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result2,true));//打印深度分页结果
$result3=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result3,true));//打印深度分页结果
//print_r($parser->explain());//打印dsl
### 普通调用
require_once dirname(__FILE__) . '/src/library/EsParser.php';
//$sql = 'select * from alp_dish_sales_saas where sid in(994,290) limit 1,10';
//$sql='update alp_dish_sales_saas set mid=3 where adsid=15125110';
//$sql='delete from alp_dish_sales_saas where adsid=15546509';
//$sql="select *,concat_ws('_',category_name.keyword,dish_name.keyword,sku_name.keyword) as dfg from alp_dish_sales_saas where sale_date>'2017-01-01' and sale_date<'2017-09-02' group by dfg order by total_count desc";
//$sql = 'select *,DATE_FORMAT(sale_date,"%Y-%m-%d") as days from alp_dish_sales_saas group by days ';
$sql="insert into test(`id`,`name`)values(9,'zz')";
$sql2="insert into test(`id`,`name`)values(9,'zz')";
$es_config=array(
'index' =>"alp_dish_sales_saas",
'type' =>"alp_dish_sales_saas",
'url' =>"http://127.0.0.1:9200",
'version' =>"5.x" //1.x 2.x 5.x 6.x 7.x,可以不配置,系统会请求获取版本,这样会多一次请求,建议配置一下
);
$parser = new EsParser($sql, true,$es_config);//第三个参数是es的配置参数,一定要配置
print_r($parser->build());//打印结果
print_r($parser->setSql($sql2)->build());//打印结果
$result=$parser->scroll();//深度分页初始化会返回第一条
$result=json_decode($result,true);
print_r($result);//打印深度分页结果
$result1=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result1,true));//打印深度分页结果
$result2=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result2,true));//打印深度分页结果
$result3=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result3,true));//打印深度分页结果
//print_r($parser->explain()); //打印dsl
### 目前支持的sql函数
* SQL Insert
* SQL Select
* SQL Delete
* SQL Update
* SQL Where
* SQL Order By
* SQL Group By
* SQL AND
* SQL OR (多重or如:((a=1 and b=2) or (c=3 and d=4)) and e=5)
* SQL Like
* SQL Not Like
* SQL Is NULL
* SQL Is Not NULL
* SQL COUNT distinct
* SQL In
* SQL Not In
* SQL =
* SQL !=
* SQL <>
* SQL avg()
* SQL count()
* SQL max()
* SQL min()
* SQL sum()
* SQL Between
* SQL Aliases
* SQL concat_ws
* SQL DATE_FORMATE
* SQL Having
### 使用注意事项
请在配置项填写es的版本,这样系统不会请求获取版本,这样不会多一次请求,建议配置一下
### 交流使用
qq群:578276199
### 项目地址
github:https://github.com/qieangel2013/EsParser
oschina:https://gitee.com/qieangel2013/EsParser
### 如果你对我的辛勤劳动给予肯定,请给我捐赠,你的捐赠是我最大的动力


[项目捐赠列表](https://github.com/qieangel2013/zys/wiki/%E9%A1%B9%E7%9B%AE%E6%8D%90%E8%B5%A0)
================================================
FILE: composer.json
================================================
{
"name": "qieangel2013/esparser",
"description": "es php library",
"type": "library",
"keywords": ["sql","elasticsearch","restful"],
"license": "MIT",
"authors": [
{
"name": "qieangel2013",
"email": "904208360@qq.com"
}
],
"require": {
"php": ">=5.3"
},
"classmap" : ["src/library/"],
"minimum-stability": "dev"
}
================================================
FILE: index.php
================================================
<?php
require_once dirname(__FILE__) . '/src/library/EsParser.php';
//$sql = 'select a.*,count(a.id) as id,sum(a.price) as total_price,sum(a.total) as count_total from table1 a where a.a=12 and a.b=36 and a.c like "%5%" and a.d>=10 and a.d<20 and a.h>56 and a.f in(1,2,3,4,5) group by a.name order by a.id desc limit 10';
//$sql='select a.*,count(a.id) as sid,a.total_price,sum(a.total) as count_total from table1 group by a.total_price order by count_total,a.co';
//$sql = 'select * from alp_dish_sales_saas where sid in(994,290) limit 0,10';
$sql='select category_name cate_name,dish_name,dishsno,sale_date,sum(total_price) total_price,sum(total_count) total_count,category_name,sku_name properties from alp_dish_sales_saas where sale_date>="2017-01-01" and sale_date<="2017-09-03" and sid in(994,290) limit 3,10';
//$sql='update alp_dish_sales_saas set mid=3 where adsid=15125110';
//$sql='delete from alp_dish_sales_saas where adsid=15546509';
$es_config=array(
'index' =>"alp_dish_sales_saas",
'type' =>"alp_dish_sales_saas",
'url' =>"http://127.0.0.1:9200",
'version' =>"5.x" //1.x 2.x 5.x 6.x,可以不配置,系统会请求获取版本,这样会多一次请求
);
$parser = new EsParser($sql, true,$es_config);//第三个参数是es的配置参数,一定要配置
print_r($parser->build());//打印结果
$result=$parser->scroll();//深度分页初始化会返回第一条
$result=json_decode($result,true);
print_r($result);//打印深度分页结果
$result1=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result1,true));//打印深度分页结果
$result2=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result2,true));//打印深度分页结果
$result3=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result3,true));//打印深度分页结果
//print_r($parser->explain()); //打印dsl
================================================
FILE: src/example.php
================================================
<?php
require_once dirname(__FILE__) . '/library/EsParser.php';
//$sql = 'select a.*,count(a.id) as id,sum(a.price) as total_price,sum(a.total) as count_total from table1 a where a.a=12 and a.b=36 and a.c like "%5%" and a.d>=10 and a.d<20 and a.h>56 and a.f in(1,2,3,4,5) group by a.name order by a.id desc limit 10';
//$sql='select a.*,count(a.id) as sid,a.total_price,sum(a.total) as count_total from table1 group by a.total_price order by count_total,a.co';
//$sql = 'select * from alp_dish_sales_saas where sid in(994,290) limit 0,10';
$sql='select category_name cate_name,dish_name,dishsno,sale_date,sum(total_price) total_price,sum(total_count) total_count,category_name,sku_name properties from alp_dish_sales_saas where sale_date>="2017-01-01" and sale_date<="2017-09-03" and sid in(994,290) limit 3,10';
//$sql='update alp_dish_sales_saas set mid=3 where adsid=15125110';
//$sql='delete from alp_dish_sales_saas where adsid=15546509';
$es_config=array(
'index' =>"alp_dish_sales_saas",
'type' =>"alp_dish_sales_saas",
'url' =>"http://127.0.0.1:9200",
'version' =>"5.x" //1.x 2.x 5.x 6.x,可以不配置,系统会请求获取版本,这样会多一次请求
);
$parser = new EsParser($sql, true,$es_config);//第三个参数是es的配置参数,一定要配置
print_r($parser->build());//打印结果
$result=$parser->scroll();//深度分页初始化会返回第一条
$result=json_decode($result,true);
print_r($result);//打印深度分页结果
$result1=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result1,true));//打印深度分页结果
$result2=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result2,true));//打印深度分页结果
$result3=$parser->scroll($result['scrollid']);//深度分页下一页
print_r(json_decode($result3,true));//打印深度分页结果
//print_r($parser->explain()); //打印dsl
================================================
FILE: src/library/EsCreator.php
================================================
<?php
/**
* PHPSQLCreator.php
*
* A creator, which generates SQL from the output of PHPSQLParser.
*
* PHP version 5
*
* LICENSE:
* Copyright (c) 2010-2014 André Rothe
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author André Rothe <andre.rothe@phosco.info>
* @copyright 2010-2014 André Rothe
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
* @version SVN: $Id: PHPSQLCreator.php 790 2013-12-17 12:16:48Z phosco@gmx.de $
*
*/
require_once dirname(__FILE__) . '/exceptions/UnsupportedFeatureException.php';
require_once dirname(__FILE__) . '/builders/SelectStatementBuilder.php';
require_once dirname(__FILE__) . '/builders/DeleteStatementBuilder.php';
require_once dirname(__FILE__) . '/builders/UpdateStatementBuilder.php';
require_once dirname(__FILE__) . '/builders/InsertStatementBuilder.php';
require_once dirname(__FILE__) . '/builders/CreateStatementBuilder.php';
require_once dirname(__FILE__) . '/builders/ShowStatementBuilder.php';
/**
* This class generates SQL from the output of the PHPSQLParser.
*
* @author André Rothe <andre.rothe@phosco.info>
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
*
*/
class PHPSQLCreator {
public function __construct($parsed = false) {
if ($parsed) {
$this->create($parsed);
}
}
public function create($parsed) {
$k = key($parsed);
switch ($k) {
case "UNION":
case "UNION ALL":
throw new UnsupportedFeatureException($k);
break;
case "SELECT":
$builder = new SelectStatementBuilder($parsed);
$this->created = $builder->build($parsed);
break;
case "INSERT":
$builder = new InsertStatementBuilder($parsed);
$this->created = $builder->build($parsed);
break;
case "DELETE":
$builder = new DeleteStatementBuilder($parsed);
$this->created = $builder->build($parsed);
break;
case "UPDATE":
$builder = new UpdateStatementBuilder($parsed);
$this->created = $builder->build($parsed);
break;
case "RENAME":
$this->created = $this->processRenameTableStatement($parsed);
break;
case "SHOW":
$builder = new ShowStatementBuilder($parsed);
$this->created = $builder->build($parsed);
break;
case "CREATE":
$builder = new CreateStatementBuilder($parsed);
$this->created = $builder->build($parsed);
break;
default:
throw new UnsupportedFeatureException($k);
break;
}
return $this->created;
}
// TODO: we should change that, there are multiple "rename objects" as
// table, user, database
protected function processRenameTableStatement($parsed) {
$rename = $parsed['RENAME'];
$sql = "";
foreach ($rename as $k => $v) {
$len = strlen($sql);
$sql .= $this->processSourceAndDestTable($v);
if ($len == strlen($sql)) {
throw new UnableToCreateSQLException('RENAME', $k, $v, 'expr_type');
}
$sql .= ",";
}
$sql = substr($sql, 0, -1);
return "RENAME TABLE " . $sql;
}
protected function processSourceAndDestTable($v) {
if (!isset($v['source']) || !isset($v['destination'])) {
return "";
}
return $v['source']['base_expr'] . " TO " . $v['destination']['base_expr'];
}
}
?>
================================================
FILE: src/library/EsParser.php
================================================
<?php
/*
|---------------------------------------------------------------
| Copyright (c) 2018
|---------------------------------------------------------------
| 作者:qieangel2013
| 联系:qieangel2013@gmail.com
| 版本:V1.0
| 日期:2018/3/13
|---------------------------------------------------------------
*/
require_once dirname(__FILE__) . '/positions/PositionCalculator.php';
require_once dirname(__FILE__) . '/processors/DefaultProcessor.php';
class EsParser {
public $parsed;
private $Builderarr;
public $url;
private $top_hits=0;
private $top_hits_size=1;
private $agg;
private $havingagg=array();
private $sort;
private $index_es='';
private $type_es='';
private $version_es='';
private $count_tmp=0;
private $count_tmp_filter=0;
private $count_tmp_range=0;
private $count_fi=0;
private $count_tmp_have=0;
private $count_tmp_filter_have=0;
private $count_tmp_range_have=0;
private $count_fi_have=0;
private $arrtmp=array();
private $tmp_str='';
private $tmp_str_filter='';
private $tmp_fi='';
private $tmp_str_range='';
private $tmp_lock='';
private $tmp_lock_str='';
private $tmp_or=0;
private $tmp_and=0;
private $tmp_lock_fi='';
private $tmp_lock_range='';
private $tmp_str_have='';
private $tmp_str_filter_have='';
private $tmp_fi_have='';
private $tmp_str_range_have='';
private $tmp_lock_have='';
private $tmp_lock_str_have='';
private $tmp_lock_fi_have='';
private $tmp_lock_range_have='';
private $fistgroup='';
private $limit;
public $result;
public $explain;
public $build;
private $scrolltime='3m';
private $scrollurl='';
private $basescrollurl='';
private $isscroll=0;
public $scroll;
/**
* Constructor. It simply calls the parse() function.
* Use the public variable $parsed to get the output.
*
* @param String $sql The SQL statement.
* @param boolean $calcPositions True, if the output should contain [position], false otherwise.
*/
public function __construct($sql = false,$calcPositions = false,$es_config=array()) {
if(empty($es_config)){
$config_err=array(
'fail' =>1,
'message'=>'es的配置项不能为空!'
);
$this->result=json_encode($config_err,true);
return $this->result;
}else{
$this->index_es=$es_config['index'];
$this->type_es=$es_config['type'];
$this->url=$es_config['url'];
$this->scrollurl=$es_config['url'];
$this->basescrollurl=$es_config['url'];
if(!isset($es_config['version'])){
$version=$this->getEsData($es_config['url']);
if($version){
if(version_compare($version,'5.0.0', '<')){
$this->version_es='2.x';
}else if( version_compare($version,'5.0.0', '>=') && version_compare($version,'6.0.0', '<')){
$this->version_es='5.x';
}else if( version_compare($version,'6.0.0', '>=') && version_compare($version,'7.0.0', '<')){
$this->version_es='6.x';
} else {
$this->version_es='7.x';
}
}else{
$this->version_es='5.x';
}
}else{
if(trim($es_config['version'])==''){
$this->version_es='5.x';
}else{
$this->version_es=$es_config['version'];
}
}
}
if ($sql) {
$this->parse($sql, $calcPositions);
}
}
/**
*
* @param String $sql The SQL statement.
* @param boolean $calcPositions True, if the output should contain [position], false otherwise.
*
* @return array An associative array with all meta information about the SQL statement.
*/
public function parsesql($sql, $calcPositions = false) {
$processor = new DefaultProcessor();
$queries = $processor->process($sql);
if ($calcPositions) {
$calculator = new PositionCalculator();
$queries = $calculator->setPositionsWithinSQL($sql, $queries);
}
$this->parsed = $queries;
return $this->parsed;
}
public function setSql($sql, $calcPositions = false) {
$this->Builderarr = [];
$this->url = $this->basescrollurl;
return $this->parse($sql, $calcPositions);
}
public function parse($sql, $calcPositions = false) {
$processor = new DefaultProcessor();
$queries = $processor->process($sql);
if ($calcPositions) {
$calculator = new PositionCalculator();
$queries = $calculator->setPositionsWithinSQL($sql, $queries);
}
$this->parsed = $queries;
return $this->EsBuilder();
//return $this->parsed;
}
private function EsBuilder(){
//table
if(isset($this->parsed['FROM']) && !empty($this->parsed['FROM'])){
$this->table($this->parsed['FROM']);
}
//insert
if(isset($this->parsed['INSERT']) && !empty($this->parsed['INSERT'])){
$this->insert($this->parsed['INSERT']);
}
//update
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->update($this->parsed['UPDATE']);
}
//set
if(isset($this->parsed['SET']) && !empty($this->parsed['SET'])){
$this->updateset($this->parsed['SET']);
}
//delete
if(isset($this->parsed['DELETE']) && !empty($this->parsed['DELETE'])){
$this->delete($this->parsed['DELETE']);
}
//limit
if(isset($this->parsed['LIMIT']) && !empty($this->parsed['LIMIT'])){
$this->limit($this->parsed['LIMIT']);
if(isset($this->parsed['GROUP']) && !empty($this->parsed['GROUP'])){
$this->Builderarr['size']=0;
$this->limit($this->parsed['LIMIT']);
}else{
$this->Builderarr['from']=$this->limit['from'] * $this->limit['size'];
$this->Builderarr['size']=$this->limit['size'];
}
}else{
$this->limit(array());
}
//having
if(isset($this->parsed['HAVING']) && !empty($this->parsed['HAVING'])){
$this->having($this->parsed['HAVING']);
}
//where
if(isset($this->parsed['WHERE']) && !empty($this->parsed['WHERE'])){
$this->where($this->parsed['WHERE']);
}
//groupby
if(isset($this->parsed['GROUP']) && !empty($this->parsed['GROUP'])){
$this->groupby($this->parsed['GROUP']);
if(!empty($this->agg['aggs'])){
$this->Builderarr['aggs']=$this->agg['aggs'];
}
}
//orderby
if(isset($this->parsed['ORDER']) && !empty($this->parsed['ORDER'])){
$this->orderby($this->parsed['ORDER']);
if(!empty($this->sort['sort'])){
$this->Builderarr['sort']=$this->sort['sort'];
}
}
//select
if(isset($this->parsed['SELECT']) && !empty($this->parsed['SELECT'])){
$this->select($this->parsed['SELECT']);
}
if(!isset($this->Builderarr) && empty($this->Builderarr)){
$this->Builderarr['query']['match_all']=(object)array();
}
return $this;
}
public function build(){
//request
return $this->PostEs($this->Builderarr);
}
public function explain(){
$this->explain=json_encode($this->Builderarr,true);
return $this->explain;
}
public function scroll($scrollid=''){
$this->isscroll=1;
if($scrollid){
$this->scrollurl=$this->basescrollurl;
$this->scrollurl .="/_search/scroll?pretty";
$this->Builderarr=array();
$this->Builderarr['scroll']=$this->scrolltime;
$this->Builderarr['scroll_id']=$scrollid;
}else{
$this->scrollurl .="/".$this->index_es."/".$this->type_es."/_search?pretty&scroll=".$this->scrolltime;
}
$this->url=$this->scrollurl;
return $this->PostEs($this->Builderarr);
}
private function table($arr){
if(isset($this->parsed['DELETE']) && !empty($this->parsed['DELETE'])){
foreach ($arr as $v) {
if($v['table']){
if ($this->version_es == '7.x'){
$this->url .="/".$this->index_es."/_delete_by_query?pretty";
}else {
$this->url .="/".$this->index_es."/".$this->type_es."/_delete_by_query?pretty";
}
}
}
}else{
foreach ($arr as $v) {
if($v['table']){
if ($this->version_es == '7.x'){
$this->url .="/".$this->index_es."/_search?pretty";
} else {
$this->url .="/".$this->index_es."/".$this->type_es."/_search?pretty";
}
}
}
}
}
private function insert($arr){
if ($this->version_es == '7.x'){
$this->url .="/".$this->index_es."?pretty";
}else {
$this->url .="/".$this->index_es."/".$this->type_es."?pretty";
}
foreach ($arr as $k=>$v) {
if(count($v['columns'])>0){
$this->Builderarr=$this->resdata($v['columns'],$this->parsed['VALUES'][$k]['data']);
}
}
}
private function resdata($data,$value){
foreach ($data as $v) {
if($v['base_expr']){
$fielddata=str_replace('`','',$v['base_expr']);
$fieldarr[]=$fielddata;
}
}
foreach ($value as $vv) {
if(strlen($vv['base_expr'])){
$fielddata=str_replace("'",'',$vv['base_expr']);
$fielddata=str_replace('"','',$fielddata);
$valuearr[]=$fielddata;
}
}
return array_combine($fieldarr,$valuearr);
}
private function update($arr){
foreach ($arr as $v) {
if($v['table']){
$this->table=$v['table'];
$this->url .="/".$this->index_es."/".$this->type_es."/";
}
}
}
private function delete($arr){
}
private function getEsData($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ;
$output = curl_exec($ch);
if($output === false) //超时处理
{
if(curl_errno($ch) == CURLE_OPERATION_TIMEDOUT)
{
my_file_put_contents("getEsData.txt", "时间:".date('Ymd-H:i:s',time())."\r\n错误内容为:curl通过get方式请求{$url}的连接超时\r\n");
}
}
curl_close($ch);
$output=json_decode($output,true);
if (empty($output)) {
return array();
}
return $output['version']['number'];
}
private function PostEs($postdata,$json=true,$token=false){
$url=$this->url;
$datastring = json_encode($postdata,true);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url) ;
curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60); //只需要设置一个秒的数量就可以
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datastring);
if ($json) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json;',
'Content-Length: ' . strlen($datastring))
);
}
if ($token) {
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($datastring),
'Authorization:'.$token
)
);
}
$output=curl_exec($ch);
if($output === false) //超时处理
{
if(curl_errno($ch) == CURLE_OPERATION_TIMEDOUT)
{
file_put_contents("getEsData.txt", "时间:".date('Ymd-H:i:s',time())."\r\n错误内容为:curl通过post方式请求{$this->url}的连接超时\r\n");
}
}
curl_close($ch);
$output=json_decode($output,true);
if (empty($output)) {
$this->result=json_encode(array(),true);
}
if(isset($output['error'])){
$this->result=json_encode($output,true);
}else if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$update_arr=$output['_shards'];
unset($update_arr['total']);
$this->result=json_encode($update_arr,true);
}else if(isset($this->parsed['DELETE']) && !empty($this->parsed['DELETE'])){
$delete_arr['total']=$output['total'];
$delete_arr['deleted']=$output['deleted'];
$delete_arr['successfull']=$output['deleted'];
$this->result=json_encode($delete_arr,true);
}else if(isset($this->parsed['INSERT']) && !empty($this->parsed['INSERT'])){
$this->result=json_encode($output,true);
}else{
if ($this->version_es == '7.x'){
$total_str=$output['hits']['total']['value'];
}else {
$total_str=$output['hits']['total'];
}
if(isset($this->parsed['GROUP']) && !empty($this->parsed['GROUP'])){
if($output['hits']['hits'] && empty($output['aggregations'][$this->fistgroup]['buckets'])){
$tmp_counter=count($output['hits']['hits']);
$counter=($this->limit['from'] + 1 )*$this->limit['size'];
if($tmp_counter<$counter){
$page=ceil($tmp_counter/$this->limit['size']);
$outputs['page']=$page==0?1:$page;
$outputs['result']=array_slice($output['hits']['hits'],($page-1)*$this->limit['size'],$tmp_counter-(($page-1)*$this->limit['size']));
}else if($tmp_counter==$counter){
$outputs['page']=$this->limit['from']+1;
$outputs['result']=array_slice($output['hits']['hits'],-$this->limit['size']);
}else{
$page=$this->limit['from']+1;
$outputs['page']=$page==0?1:$page;
$outputs['result']=array_slice($output['hits']['hits'],($page-1)*$this->limit['size'],$this->limit['size']);
}
}else if(isset($output['aggregations'][$this->fistgroup]['buckets']) && !empty($output['aggregations'][$this->fistgroup]['buckets'])){
$tmp_counter=count($output['aggregations'][$this->fistgroup]['buckets']);
$counter=($this->limit['from'] + 1 )*$this->limit['size'];
if($tmp_counter<$counter){
$page=ceil($tmp_counter/$this->limit['size']);
$outputs['page']=$page==0?1:$page;
$outputs['result'][$this->fistgroup]['buckets']=array_slice($output['aggregations'][$this->fistgroup]['buckets'],($page-1)*$this->limit['size'],$tmp_counter-(($page-1)*$this->limit['size']));
}else if($tmp_counter==$counter){
$outputs['page']=$this->limit['from']+1;
$outputs['result'][$this->fistgroup]['buckets']=array_slice($output['aggregations'][$this->fistgroup]['buckets'],-$this->limit['size']);
}else{
$page=$this->limit['from']+1;
$outputs['page']=$page==0?1:$page;
$outputs['result'][$this->fistgroup]['buckets']=array_slice($output['aggregations'][$this->fistgroup]['buckets'],($page-1)*$this->limit['size'],$this->limit['size']);
}
}else{
$tmp_counter=count($output['aggregations'][$this->fistgroup]['buckets']);
$counter=($this->limit['from'] + 1 )*$this->limit['size'];
if($tmp_counter<$counter){
$page=ceil($tmp_counter/$this->limit['size']);
$outputs['page']=$page==0?1:$page;
$outputs['result']=array_slice($output['aggregations'][$this->fistgroup]['buckets'],($page-1)*$this->limit['size'],$tmp_counter-(($page-1)*$this->limit['size']));
}else if($tmp_counter==$counter){
$outputs['page']=$this->limit['from']+1;
$outputs['result']=array_slice($output['aggregations'][$this->fistgroup]['buckets'],-$this->limit['size']);
}
}
}else{
if(isset($output['aggregations']) && !empty($output['aggregations'])){
$outputs['result']=$output['aggregations'];
}else{
$page_tmp=ceil($total_str/$this->limit['size']);
$page=$this->limit['from'] + 1 ;
if($page_tmp>=$page){
}else{
$page=$page_tmp;
if($page_tmp!=0){
$this->Builderarr['from']=($page_tmp-1) * $this->limit['size']+1;
}else{
$this->Builderarr['from']=0;
}
$this->Builderarr['size']=$this->limit['size'];
}
$outputs['page']=$page==0?1:$page;
$outputs['result']=$output['hits']['hits'];
}
}
$outputs['total']=$total_str;
if($this->isscroll && isset($output['_scroll_id'])){
$outputs['scrollid']=$output['_scroll_id'];
}
$this->result=json_encode($outputs,true);
}
return $this->result;
}
private function where($arr){
for($i=0;$i<count($arr);$i++){
if($arr[$i]['expr_type']=='bracket_expression'){
if($arr[$i]['sub_tree']){
if(count($arr[$i]['sub_tree'])>1){
if(isset($arr[$i]['sub_tree'][0]['expr_type']) && $arr[$i]['sub_tree'][0]['expr_type']=='bracket_expression'){
for($jj=0;$jj<count($arr[$i]['sub_tree']);$jj++){
$this->whereor($arr[$i]['sub_tree'],$jj);
}
}else{
$tmp_arr=$arr[$i]['sub_tree'];
for($j=0;$j<count($tmp_arr);$j++){
$this->whereext($tmp_arr,$j);
}
}
}else{
if(isset($arr[$i]['sub_tree'][0]['expr_type']) && $arr[$i]['sub_tree'][0]['expr_type']=='bracket_expression'){
$tmp_arr=$arr[$i]['sub_tree'][0]['sub_tree'];
}else{
$tmp_arr=$arr[$i]['sub_tree'];
}
for($j=0;$j<count($tmp_arr);$j++){
$this->whereext($tmp_arr,$j);
}
}
}
}else{
$this->whereext($arr,$i);
}
}
}
private function whereorext($arr){
$tmp_or=array();
for($i=0;$i<count($arr);$i++){
if(!is_numeric($arr[$i]['base_expr'])){
$lowerstr = strtolower($arr[$i]['base_expr']);
}else{
$lowerstr = $arr[$i]['base_expr'];
}
switch ($lowerstr) {
case '=':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='and' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='and'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$tmp_or['bool']['must'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$tmp_or['bool']['must'][]=$term;
}
}else{
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$tmp_or['bool']['must'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$tmp_or['bool']['must'][]=$term;
}
}
break;
case '!=':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='and' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='and'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$tmp_or['bool']['must_not'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$tmp_or['bool']['must_not'][]=$term;
}
}else{
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$tmp_or['bool']['must_not'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$tmp_or['bool']['must_not'][]=$term;
}
}
break;
case '<>':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='and' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='and'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$tmp_or['bool']['must_not'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$tmp_or['bool']['must_not'][]=$term;
}
}else{
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$tmp_or['bool']['must_not'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$tmp_or['bool']['must_not'][]=$term;
}
}
break;
case 'in':
if(strtolower($arr[$i-1]['base_expr'])=='not'){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
if(isset($arr[$i+1]['sub_tree']) && !empty($arr[$i+1]['sub_tree'])){
foreach ($arr[$i+1]['sub_tree'] as &$vv) {
if(!is_numeric($vv['base_expr']) && $this->version_es=='8.x'){
$termk .='.keyword';
}
$tmp_da_str=str_replace('"','',$vv['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$tmp_or['terms'][$termk][]=$tmp_da_str;
}
}
break;
case 'not':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
switch (strtolower($arr[$i+1]['base_expr'])) {
case 'in':
if(isset($arr[$i+2]['sub_tree']) && !empty($arr[$i+2]['sub_tree'])){
foreach ($arr[$i+2]['sub_tree'] as &$vv) {
if(!is_numeric($vv['base_expr']) && $this->version_es=='8.x'){
$termk .='.keyword';
}
$tmp_da_str=str_replace('"','',$vv['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$tmp_or['bool']['must_not']['terms'][$termk][]=$tmp_da_str;
}
}
break;
case 'like':
$tmp_la_str=str_replace('"','',$arr[$i+2]['base_expr']);
$tmp_la_str=str_replace("'","",$tmp_la_str);
if(!is_numeric($arr[$i+2]['base_expr']) && $this->version_es=='8.x'){
//$term['match_phrase'][$termk.'.keyword']=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk.'.keyword']=str_replace("%","*",$tmp_la_str);
$tmp_or['bool']['must_not'][]=$term;
}else{
//$term['match_phrase'][$termk]=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk]=str_replace("%","*",$tmp_la_str);
$tmp_or['bool']['must_not'][]=$term;
}
break;
case 'null':
$tmp_or['exists']['field']=$arr[$i-2]['base_expr'];
break;
}
break;
case 'is':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strtolower($arr[$i+1]['base_expr'])=='not'){
break;
}
$tmp_or['bool']['must_not'][]['exists']['field']=$arr[$i-1]['base_expr'];
break;
case '>':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
$tmp_or['range'][$termk]['gt']=$tmp_da_str;
if(!isset($tmp_or['range'][$termk]['time_zone']) && $is_date){
$tmp_or['range'][$termk]['time_zone']="+08:00";
}
break;
case '>=':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
$tmp_or['range'][$termk]['gte']=$tmp_da_str;
if(!isset($tmp_or['range'][$termk]['time_zone']) && $is_date){
$tmp_or['range'][$termk]['time_zone']="+08:00";
}
break;
case '<':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
$tmp_or['range'][$termk]['lt']=$tmp_da_str;
if(!isset($tmp_or['range'][$termk]['time_zone']) && $is_date){
$tmp_or['range'][$termk]['time_zone']="+08:00";
}
break;
case '<=':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
$tmp_or['range'][$termk]['lte']=$tmp_da_str;
if(!isset($tmp_or['range'][$termk]['time_zone']) && $is_date){
$tmp_or['range'][$termk]['time_zone']="+08:00";
}
break;
case 'like':
if(strtolower($arr[$i-1]['base_expr'])=='not'){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_la_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_la_str=str_replace("'","",$tmp_la_str);
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
//$term['match_phrase'][$termk.'.keyword']=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk.'.keyword']=str_replace("%","*",$tmp_la_str);
$tmp_or['bool']['must'][]=$term;
}else{
//$term['match_phrase'][$termk]=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk]=str_replace("%","*",$tmp_la_str);
$tmp_or['bool']['must'][]=$term;
}
break;
case 'between':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
$tmp_or['range'][$termk]['gte']=$tmp_da_str;
if(!isset($tmp_or['range'][$termk]['time_zone']) && $is_date){
$tmp_or['range'][$termk]['time_zone']="+08:00";
}
$tmp_da_str=str_replace('"','',$arr[$i+3]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$tmp_or['range'][$termk]['lte']=$tmp_da_str;
break;
}
}
return $tmp_or;
}
private function whereorink($arr,$i){
$tmparrs=$arr;
if(isset($tmparrs[$i]['base_expr']) && strtolower($tmparrs[$i]['base_expr'])!='or'){
$this->arrtmp[]=$arr[$i];
$i=$i+1;
$this->whereorink($tmparrs,$i);
}
return $this->arrtmp;
}
private function whereor($arr,$i){
if(!is_numeric($arr[$i]['base_expr'])){
$lowerstr = strtolower($arr[$i]['base_expr']);
}else{
$lowerstr = $arr[$i]['base_expr'];
}
switch ($lowerstr) {
case 'or':
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter=='' && !$this->tmp_or){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}
}
if(!isset($arr[$i-2])){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]['bool']['should'][]=$this->whereorext($arr[$i-1]['sub_tree']);
}
if($arr[$i+1]['expr_type']=='bracket_expression'){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]['bool']['should'][]=$this->whereorext($arr[$i+1]['sub_tree']);
}else{
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]['bool']['should'][]=$this->whereorext($this->whereorink($arr,$i+1));
$this->arrtmp=array();
}
$this->tmp_or=1;
break;
case 'and':
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter=='' && !$this->tmp_and){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(!isset($arr[$i-2])){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][]=$this->whereorext($arr[$i-1]['sub_tree']);
}
if($arr[$i+1]['expr_type']=='bracket_expression'){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][]=$this->whereorext($arr[$i+1]['sub_tree']);
}else{
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][]=$this->whereorext($this->whereorink($arr,$i+1));
$this->arrtmp=array();
}
$this->tmp_and=1;
break;
}
}
private function whereext($arr,$i){
if(!is_numeric($arr[$i]['base_expr'])){
$lowerstr = strtolower($arr[$i]['base_expr']);
}else{
$lowerstr = $arr[$i]['base_expr'];
}
switch ($lowerstr) {
case '=':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_tmp]['bool']['should'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_tmp]['bool']['should'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock=$lowerstr;
$this->tmp_lock_str=$lowerstr;
}else if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='and' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='and'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock_str=$lowerstr;
}else{
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][]=$term;
}
unset($term['match_phrase']);
$this->tmp_lock_str=$lowerstr;
}
$this->tmp_lock=$lowerstr;
$this->tmp_str=$lowerstr;
break;
case '!=':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][$this->count_tmp]['bool']['should'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][$this->count_tmp]['bool']['should'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock=$lowerstr;
$this->tmp_lock_str=$lowerstr;
}else if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='and' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='and'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock_str=$lowerstr;
}else{
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}
unset($term['match_phrase']);
$this->tmp_lock_str=$lowerstr;
}
$this->tmp_lock=$lowerstr;
$this->tmp_str=$lowerstr;
break;
case '<>':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][$this->count_tmp]['bool']['should'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][$this->count_tmp]['bool']['should'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock=$lowerstr;
$this->tmp_lock_str=$lowerstr;
}else if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='and' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='and'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock_str=$lowerstr;
}else{
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}
unset($term['match_phrase']);
$this->tmp_lock_str=$lowerstr;
}
$this->tmp_lock=$lowerstr;
$this->tmp_str=$lowerstr;
break;
case 'in':
if(strtolower($arr[$i-1]['base_expr'])=='not'){
break;
}
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter']['bool']['should'][$this->count_tmp]) && $this->tmp_lock_str!='' && $this->tmp_lock_str==$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
if(isset($arr[$i+1]['sub_tree']) && !empty($arr[$i+1]['sub_tree'])){
foreach ($arr[$i+1]['sub_tree'] as &$vv) {
if(!is_numeric($vv['base_expr']) && $this->version_es=='8.x'){
$termk .='.keyword';
}
$tmp_da_str=str_replace('"','',$vv['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$this->Builderarr['query']['bool']['filter']['bool']['should'][$this->count_tmp]['terms'][$termk][]=$tmp_da_str;
}
}
}else{
if(isset($arr[$i+1]['sub_tree']) && !empty($arr[$i+1]['sub_tree'])){
if ($this->version_es == '7.x'){
$this->count_tmp_filter++;
}
foreach ($arr[$i+1]['sub_tree'] as &$vv) {
if(!is_numeric($vv['base_expr']) && $this->version_es=='8.x'){
$termk .='.keyword';
}
$tmp_da_str=str_replace('"','',$vv['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['terms'][$termk][]=$tmp_da_str;
}
}
}
$this->tmp_lock=$lowerstr;
$this->tmp_str=$termk;
unset($termk);
break;
case 'not':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
switch (strtolower($arr[$i+1]['base_expr'])) {
case 'in':
if(isset($arr[$i+2]['sub_tree']) && !empty($arr[$i+2]['sub_tree'])){
foreach ($arr[$i+2]['sub_tree'] as &$vv) {
if(!is_numeric($vv['base_expr']) && $this->version_es=='8.x'){
$termk .='.keyword';
}
$tmp_da_str=str_replace('"','',$vv['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not']['terms'][$termk][]=$tmp_da_str;
}
}
break;
case 'like':
$tmp_la_str=str_replace('"','',$arr[$i+2]['base_expr']);
$tmp_la_str=str_replace("'","",$tmp_la_str);
if(!is_numeric($arr[$i+2]['base_expr']) && $this->version_es=='8.x'){
// $term['match_phrase'][$termk.'.keyword']=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk.'.keyword']=str_replace("%","*",$tmp_la_str);
$this->Builderarr['query']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}else{
//$term['match_phrase'][$termk]=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk]=str_replace("%","*",$tmp_la_str);
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]=$term;
}
break;
case 'null':
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['exists']['field']=$arr[$i-2]['base_expr'];
break;
}
$this->tmp_lock=$lowerstr;
$this->tmp_str=$termk;
unset($termk);
break;
case 'is':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strtolower($arr[$i+1]['base_expr'])=='not'){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must_not'][]['exists']['field']=$arr[$i-1]['base_expr'];
$this->tmp_lock=$lowerstr;
$this->tmp_str=$termk;
unset($termk);
break;
case '>':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi==$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][0]) && $this->tmp_lock_range!=''){
if($this->tmp_str_range==''){
$this->count_tmp_range++;
}else if($this->tmp_str_range!='' && $this->tmp_str_range!=$termk){
$this->count_tmp_range++;
}
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['gt']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']="+08:00";
}
}else{
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range']) && $this->tmp_lock!='' ){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['gt']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']="+08:00";
}
}
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_range=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case '>=':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi==$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][0]) && $this->tmp_lock_range!='' ){
if($this->tmp_str_range==''){
$this->count_tmp_range++;
}else if($this->tmp_str_range!='' && $this->tmp_str_range!=$termk){
$this->count_tmp_range++;
}
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['gte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']="+08:00";
}
}else{
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range']) && $this->tmp_lock!='' ){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['gte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']="+08:00";
}
}
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_range=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case '<':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi==$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][0]) && $this->tmp_lock_range!=''){
if($this->tmp_str_range==''){
$this->count_tmp_range++;
}else if($this->tmp_str_range!='' && $this->tmp_str_range!=$termk){
$this->count_tmp_range++;
}
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['lt']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']="+08:00";
}
}else{
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str==$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}
}
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range']) && $this->tmp_lock!='' ){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['lt']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']="+08:00";
}
}
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_range=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case '<=':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock==$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi==$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][0]) && $this->tmp_lock_range!='' ){
if($this->tmp_str_range==''){
$this->count_tmp_range++;
}else if($this->tmp_str_range!='' && $this->tmp_str_range!=$termk){
$this->count_tmp_range++;
}
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['lte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][$this->count_tmp_range]['range'][$termk]['time_zone']="+08:00";
}
}else{
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str==$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range']) && $this->tmp_lock!=''){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp_filter++;
}
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['lte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']="+08:00";
}
}
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_range=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case 'like':
if(strtolower($arr[$i-1]['base_expr'])=='not'){
break;
}
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_la_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_la_str=str_replace("'","",$tmp_la_str);
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][0]) && $this->tmp_lock_fi!='' && $this->tmp_lock_fi!=$lowerstr){
if($this->tmp_fi==''){
$this->count_fi++;
}else if($this->tmp_fi!='' && $this->tmp_fi!=$termk){
$this->count_fi++;
}
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
//$term['match_phrase'][$termk.'.keyword']=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk.'.keyword']=str_replace("%","*",$tmp_la_str);
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][]=$term;
}else{
//$term['match_phrase'][$termk]=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk]=str_replace("%","*",$tmp_la_str);
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][$this->count_fi]['bool']['should'][]=$term;
}
}else{
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
//$term['match_phrase'][$termk.'.keyword']=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk.'.keyword']=str_replace("%","*",$tmp_la_str);
$this->Builderarr['query']['filter'][$this->count_tmp_filter]['must'][$this->count_tmp]['bool']['must'][]=$term;
}else{
//$term['match_phrase'][$termk]=str_replace("%","",$tmp_la_str);
$term['wildcard'][$termk]=str_replace("%","*",$tmp_la_str);
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['bool']['must'][]=$term;
}
}
unset($term['wildcard']);
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
$this->tmp_lock_fi=$lowerstr;
break;
case 'between':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
}else{
$termk=$arr[$i-1]['base_expr'];
}
if(isset($this->Builderarr['query']['bool']['filter'][0]) && $this->tmp_lock_str!='' && $this->tmp_lock_str!=$lowerstr){
if($this->tmp_str==''){
$this->count_tmp++;
}else if($this->tmp_str!='' && $this->tmp_str!=$termk){
$this->count_tmp++;
}
}
if(isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]) && $this->tmp_lock!='' && $this->tmp_lock!=$lowerstr){
if($this->tmp_str_filter==''){
$this->count_tmp_filter++;
}else if($this->tmp_str_filter!='' && $this->tmp_str_filter!=$termk){
$this->count_tmp_filter++;
}
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['gte']=$tmp_da_str;
if(!isset($this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']) && $is_date){
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['time_zone']="+08:00";
}
$tmp_da_str=str_replace('"','',$arr[$i+3]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$this->Builderarr['query']['bool']['filter'][$this->count_tmp_filter]['range'][$termk]['lte']=$tmp_da_str;
$this->tmp_str=$termk;
$this->tmp_lock_str=$lowerstr;
$this->tmp_lock=$lowerstr;
break;
}
}
private function listtree($arr,$aggs,$order){
$countmp=0;
for($i=count($arr)-1;$i>=0;$i--){
if(isset($arr[$i-1])){
$key_arr=array_keys($arr[$i]);
if($countmp==0){
if(!isset($arr[$i][$key_arr[0]]['date_histogram'])){
$arr[$i][$key_arr[0]]['terms']['size']=($this->limit['from'] + 1 )*$this->limit['size'];
if($order){
$arr[$i][$key_arr[0]]['terms']['order']=$order['order'];
}
}
if(isset($aggs['aggs'])){
if(isset($this->havingagg['having']) && !empty($this->havingagg['having'])){
$aggs['aggs']['having']=$this->havingagg['having'];
}
$arr[$i][$key_arr[0]]['aggs']=$aggs['aggs'];
}
$arr[$i][$key_arr[0]]['aggs']['top']['top_hits']['size']=$this->top_hits;
$countmp=1;
}
$key_pre=array_keys($arr[$i-1]);
$arr[$i-1][$key_pre[0]]['aggs']=$arr[$i];
unset($arr[$i]);
}else{
if(count($arr)==1 && $countmp==0){
$key_arrs=array_keys($arr[$i]);
if(!isset($arr[$i][$key_arrs[0]]['date_histogram'])){
$arr[$i][$key_arrs[0]]['terms']['size']=($this->limit['from'] + 1 )*$this->limit['size'];
if($order){
$arr[$i][$key_arrs[0]]['terms']['order']=$order['order'];
}
}
if(isset($aggs['aggs'])){
if(isset($this->havingagg['having']) && !empty($this->havingagg['having'])){
$aggs['aggs']['having']=$this->havingagg['having'];
}
$arr[$i][$key_arrs[0]]['aggs']=$aggs['aggs'];
}
$arr[$i][$key_arrs[0]]['aggs']['top']['top_hits']['size']=$this->top_hits;
$countmp=1;
}
}
}
return $arr;
}
private function groupby($arr){
$aggs= array();
$agg= array();
$agg_orderby=array();
for($i=0; $i <count($arr); $i++) {
if(strrpos($arr[$i]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i]['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
$termk_tmp=$termk;
}else{
$termk=$arr[$i]['base_expr'];
$termk_tmp=$term_tmp_arr[0];
}
}else{
$termk=$arr[$i]['base_expr'];
$termk_tmp=$termk;
}
if(isset($this->fistgroup) && $this->fistgroup==''){
$this->fistgroup=$termk_tmp;
}
$agg[$i][$termk_tmp]['terms']['field']=$termk;
$agg[$i][$termk_tmp]['terms']['size']=($this->limit['from'] + 1 )*$this->limit['size'];
}
if(isset($this->parsed['SELECT']) && !empty($this->parsed['SELECT'])){
foreach ($this->parsed['SELECT'] as $v) {
$this->top_hits=1;
if(strrpos($v['base_expr'],"*")){
//$this->top_hits=1;
}else{
if($v['expr_type']=='aggregate_function' || $v['expr_type']=='function'){
$lowerstr = strtolower($v['base_expr']);
switch ($lowerstr) {
case 'count':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
if($term_tmp_arrs[1]!='keyword'){
$cardinalitys[$v['alias']['name']]['cardinality']['field']=$term_tmp_arrs[1];
}else{
$cardinalitys[$v['alias']['name']]['cardinality']['field']=$v['sub_tree'][0]['base_expr'];
}
}else{
$cardinalitys[$v['alias']['name']]['cardinality']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
case 'sum':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
if (!isset($v['alias']['name'])) {
$v['alias']['name']='sum'.$term_tmp_arrs[1];
}
$cardinalitys[$v['alias']['name']]['sum']['field']=$term_tmp_arrs[1];
}else{
if (!isset($v['alias']['name'])) {
$v['alias']['name']='sum'.$v['sub_tree'][0]['base_expr'];
}
$cardinalitys[$v['alias']['name']]['sum']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
case 'min':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
$cardinalitys[$v['alias']['name']]['min']['field']=$term_tmp_arrs[1];
}else{
$cardinalitys[$v['alias']['name']]['min']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
case 'max':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
$cardinalitys[$v['alias']['name']]['max']['field']=$term_tmp_arrs[1];
}else{
$cardinalitys[$v['alias']['name']]['max']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
case 'avg':
if(strrpos($v['sub_tree'][0]['base_expr'],".")){
$term_tmp_arrs=explode(".",$v['sub_tree'][0]['base_expr']);
$cardinalitys[$v['alias']['name']]['avg']['field']=$term_tmp_arrs[1];
}else{
$cardinalitys[$v['alias']['name']]['avg']['field']=$v['sub_tree'][0]['base_expr'];
}
$tmmp=1;
$agggs['aggs']=$cardinalitys;
$aggs=array_merge_recursive($aggs, $agggs);
unset($cardinalitys);
break;
case 'concat_ws':
$tmp_script='';
$tmp_ps='';
if(isset($v['alias']) && !empty($v['alias'])){
foreach ($agg as $kk => $ve) {
$key_arr=array_keys($ve);
if(isset($ve[$key_arr[0]]['terms']['field']) && $v['alias']['name']==$ve[$key_arr[0]]['terms']['field']){
foreach ($v['sub_tree'] as $ke => $va) {
if($va['expr_type']=='const'){
$tmp_ps=str_replace('"','',$va['base_expr']);
$tmp_ps=str_replace("'","",$tmp_ps);
}
if($va['expr_type']=='colref'){
$tmp_script .="'".$tmp_ps."' + doc['".$va['base_expr']."'].value + ";
}
}
$tmp_script=substr($tmp_script,6,strlen($tmp_script)-8);
$agg[$kk][$key_arr[0]]['terms']['script']['source']=$tmp_script;
$agg[$kk][$key_arr[0]]['terms']['script']['lang']='painless';
unset($agg[$kk][$key_arr[0]]['terms']['field']);
}
}
}
break;
case 'date_format':
$tmp_script='';
$tmp_ps='';
if(isset($v['alias']) && !empty($v['alias'])){
foreach ($agg as $kk => $ve) {
$key_arr=array_keys($ve);
if(isset($ve[$key_arr[0]]['terms']['field']) && $v['alias']['name']==$ve[$key_arr[0]]['terms']['field']){
for ($jj=0;$jj<=count($v['sub_tree'])-1;$jj++) {
if($v['sub_tree'][$jj]['expr_type']=='const'){
$tmp_ps=str_replace('"','',$v['sub_tree'][$jj]['base_expr']);
$tmp_ps=str_replace("'","",$tmp_ps);
$tmp_ps=str_replace("%","",$tmp_ps);
$tmp_ps=str_replace("/","",$tmp_ps);
$tmp_ps=str_replace("-","",$tmp_ps);
switch ($tmp_ps) {
case 'Ymd':
$agg[$kk][$key_arr[0]]['date_histogram']['interval']="day";
break;
case 'Ym':
$agg[$kk][$key_arr[0]]['date_histogram']['interval']="month";
$agg[$kk][$key_arr[0]]['date_histogram']['format']="yyyy-MM";
break;
case 'Y':
$agg[$kk][$key_arr[0]]['date_histogram']['interval']="year";
$agg[$kk][$key_arr[0]]['date_histogram']['format']="yyyy";
break;
case 'Yu':
$agg[$kk][$key_arr[0]]['date_histogram']['interval']="week";
break;
case 'H':
$agg[$kk][$key_arr[0]]['date_histogram']['interval']="hour";
break;
case 'i':
$agg[$kk][$key_arr[0]]['date_histogram']['interval']="minute";
break;
}
}
if($v['sub_tree'][$jj]['expr_type']=='colref'){
$agg[$kk][$key_arr[0]]['date_histogram']['field']=$v['sub_tree'][$jj]['base_expr'];
$agg[$kk][$key_arr[0]]['date_histogram']['format']="yyyy-MM-dd";
$agg[$kk][$key_arr[0]]['date_histogram']['time_zone']="+08:00";
unset($agg[$kk][$key_arr[0]]['terms']);
}
}
}
}
}
break;
}
if(isset($this->parsed['ORDER']) && !empty($this->parsed['ORDER'])){
foreach ($this->parsed['ORDER'] as $vv) {
if($vv['base_expr']==$v['alias']['name']){
$agg_orderby['order'][$vv['base_expr']]=$vv['direction'];
}
}
}
}
}
}
}
$tmp_tree=$this->listtree($agg,$aggs,$agg_orderby);
$this->agg['aggs']=$tmp_tree[0];
}
private function orderby($arr){
if(isset($this->parsed['SELECT']) && !empty($this->parsed['SELECT'])){
foreach ($this->parsed['SELECT'] as $v) {
foreach ($arr as $kk=>$vv) {
if($v['alias']){
if($v['alias']['name']==$vv['base_expr']){
unset($arr[$kk]);
}
}
}
}
}
foreach ($arr as &$va) {
if(strrpos($va['base_expr'],".")){
$term_tmp_arr=explode(".",$va['base_expr']);
if($term_tmp_arr[1]!='keyword'){
$termk=$term_tmp_arr[1];
}else{
$termk=$va['base_expr'];
}
}else{
$termk=$va['base_expr'];
}
$this->sort['sort'][][$termk]['order']=$va['direction'];
}
}
private function limit($arr){
if(!isset($arr['offset'])){
$this->limit['from']=0;
}else{
$this->limit['from']=$arr['offset'];
}
if(!isset($arr['rowcount'])){
$this->limit['size']=10;
}else{
$this->limit['size']=$arr['rowcount'];
}
}
private function haveext($arr,$i){
if(!is_numeric($arr[$i]['base_expr'])){
$lowerstr = strtolower($arr[$i]['base_expr']);
}else{
$lowerstr = $arr[$i]['base_expr'];
}
switch ($lowerstr) {
case '=':
if($arr[$i-1]['base_expr']==$arr[$i+1]['base_expr']){
break;
}
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->havingagg['having']['filter']) && $this->tmp_lock_have!='' && $this->tmp_lock_have!=$lowerstr){
if($this->tmp_str_filter_have==''){
$this->count_tmp_filter_have++;
}else if($this->tmp_str_filter_have!='' && $this->tmp_str_filter_have!=$termk){
$this->count_tmp_filter_have++;
}
}else if($this->tmp_str_have!='' && $this->tmp_str_have!=$termk){
$this->count_tmp_filter_have++;
}
if(isset($this->havingagg['having']['filter']['bool']['must'][0]) && $this->tmp_lock_str_have!='' && $this->tmp_lock_str_have!=$lowerstr){
if($this->tmp_str_have==''){
$this->count_tmp_have++;
}else if($this->tmp_str_have!='' && $this->tmp_str_have!=$termk){
$this->count_tmp_have++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->havingagg['having']['filter']['bool']['must'][$this->count_tmp_have]['bool']['should'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->havingagg['having']['filter']['bool']['must'][$this->count_tmp_have]['bool']['should'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock=$lowerstr;
$this->tmp_lock_str=$lowerstr;
}else if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='and' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='and'){
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
if(isset($this->havingagg['having']['filter']) && $this->tmp_lock_str_have!='' && $this->tmp_lock_str_have!=$lowerstr){
if($this->tmp_str_have==''){
$this->count_tmp_have++;
}else if($this->tmp_str_have!='' && $this->tmp_str_have!=$termk){
$this->count_tmp_have++;
}
}
if(isset($this->parsed['UPDATE']) && !empty($this->parsed['UPDATE'])){
$this->url .=$tmp_da_str ."/_update?pretty";
}else{
if(isset($this->havingagg['having']['filter']) && $this->tmp_lock_have!='' && $this->tmp_lock_have!=$lowerstr){
if($this->tmp_str_filter_have==''){
$this->count_tmp_filter_have++;
}else if($this->tmp_str_filter_have!='' && $this->tmp_str_filter_have!=$termk){
$this->count_tmp_filter_have++;
}
}else if($this->tmp_str_have!='' && $this->tmp_str_have!=$termk){
$this->count_tmp_filter_have++;
}
if(!is_numeric($arr[$i+1]['base_expr']) && $this->version_es=='8.x'){
$term['match_phrase'][$termk.'.keyword']['query']=$tmp_da_str;
$this->havingagg['having']['filter']['bool']['must'][]=$term;
}else{
$term['match_phrase'][$termk]['query']=$tmp_da_str;
$this->havingagg['having']['filter']['bool']['must'][]=$term;
}
unset($term['match_phrase']);
}
$this->tmp_lock_str_have=$lowerstr;
}
$this->tmp_lock_have=$lowerstr;
$this->tmp_str_have=$lowerstr;
break;
case 'in':
if(strtolower($arr[$i-1]['base_expr'])=='not'){
break;
}
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
if(isset($this->havingagg['having']['filter']) && $this->tmp_lock_have!='' && $this->tmp_lock_have==$lowerstr){
if($this->tmp_str_filter_have==''){
$this->count_tmp_filter_have++;
}else if($this->tmp_str_filter_have!='' && $this->tmp_str_filter_have!=$termk){
$this->count_tmp_filter_have++;
}
}else if($this->tmp_str_have!='' && $this->tmp_str_have!=$termk){
$this->count_tmp_filter_have++;
}
if(isset($arr[$i+1]['sub_tree']) && !empty($arr[$i+1]['sub_tree'])){
foreach ($arr[$i+1]['sub_tree'] as &$vv) {
if(!is_numeric($vv['base_expr']) && $this->version_es=='5.x'){
$termk .='.keyword';
}
$tmp_da_str=str_replace('"','',$vv['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$this->havingagg['having']['filter']['terms'][$termk][]=$tmp_da_str;
}
}
$this->tmp_lock_have=$lowerstr;
$this->tmp_str_have=$termk;
unset($termk);
break;
case 'not':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
if(isset($this->havingagg['having']['filter']) && $this->tmp_lock_have!='' && $this->tmp_lock_have==$lowerstr){
if($this->tmp_str_filter_have==''){
$this->count_tmp_filter_have++;
}else if($this->tmp_str_filter_have!='' && $this->tmp_str_filter_have!=$termk){
$this->count_tmp_filter_have++;
}
}else if($this->tmp_str_have!='' && $this->tmp_str_have!=$termk){
$this->count_tmp_filter_have++;
}
if(isset($arr[$i+2]['sub_tree']) && !empty($arr[$i+2]['sub_tree'])){
foreach ($arr[$i+2]['sub_tree'] as &$vv) {
if(!is_numeric($vv['base_expr']) && $this->version_es=='5.x'){
$termk .='.keyword';
}
$tmp_da_str=str_replace('"','',$vv['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$this->havingagg['having']['filter']['bool']['must_not']['terms'][$termk][]=$tmp_da_str;
}
}
$this->tmp_lock_have=$lowerstr;
$this->tmp_str_have=$termk;
unset($termk);
break;
case '>':
if(strrpos($arr[$i-1]['base_expr'],".")){
$term_tmp_arr=explode(".",$arr[$i-1]['base_expr']);
$termk=$term_tmp_arr[1];
}else{
$termk=$arr[$i-1]['base_expr'];
}
$tmp_da_str=str_replace('"','',$arr[$i+1]['base_expr']);
$tmp_da_str=str_replace("'","",$tmp_da_str);
$is_date=strtotime($tmp_da_str)?strtotime($tmp_da_str):false;
if(isset($arr[$i+2]['base_expr']) && strtolower($arr[$i+2]['base_expr'])=='or' || isset($arr[$i-2]['base_expr']) && strtolower($arr[$i-2]['base_expr'])=='or'){
if(isset($this->havingagg['having']['filter']) && $this->tmp_lock_have!='' && $this->tmp_lock_have==$lowerstr){
if($this->tmp_str_filter_have==''){
$this->count_tmp_filter_have++;
}else if($this->tmp_str_filter_have!='' && $this->tmp_str_filter_have!=$termk){
$this->count_tmp_filter_have++;
}
}
if(isset($this->havingagg['having']['filter']['bool']['must'][0]) && $this->tmp_lock_fi_have!='' && $this->tmp_lock_fi_have==$lowerstr){
if($this->tmp_fi_have==''){
$this->count_fi_have++;
}else if($this->tmp_fi_have!='' && $this->tmp_fi_have!=$termk){
$this->count_fi_have++;
}
}
if(isset($this->havingagg['having']['filter']['bool']['must'][$this->count_fi_have]['bool']['should'][0]) && $this->tmp_lock_range_have!=''){
if($this->tmp_str_range_have==''){
$this->count_tmp_range_have++;
}else if($this->tmp_str_range_have!='' && $this->tmp_str_range_have!=$termk){
$this->count_tmp_range_have++;
}
}
$this->havingagg['having']['filter']['bool']['must'][$this->count_fi_have]['bool']['should'][$this->count_tmp_range_have]['range'][$termk]['gt']=$tmp_da_str;
if(!isset($this->havingagg['having']['filter']['bool']['must'][$this->count_fi_have]['bool']['should'][$this->count_tmp_range_have]['range'][$termk]['time_zone']) && $is_date){
$this->havingagg['having']['filter']['bool']['must'][$this->count_fi_have]['bool']['should'][$this->count_tmp_range_have]['range'][$termk]['time_zone']="+08:00";
}
}else{
if(isset($this->havingagg['having']['filter']) && $this->tmp_lock_str_have!='' && $this->tmp_lock_str_have!=$lowerstr){
if($this->tmp_str_have==''){
$this->count_tmp_have++;
}else if($this->tmp_str_have!='' && $this->tmp_str_have!=$termk){
$this->count_tmp_have++;
}
}
if(!isset($this->havingagg['having']['filter']['range']) && $this->tmp_lock_have!='' ){
if($this->tmp_str_filter_have==''){
$this->count_tmp_filter_have++;
gitextract_02kj_sub/
├── EsParser_realse.php
├── README.md
├── composer.json
├── index.php
└── src/
├── example.php
└── library/
├── EsCreator.php
├── EsParser.php
├── builders/
│ ├── AliasBuilder.php
│ ├── CharacterSetBuilder.php
│ ├── CheckBuilder.php
│ ├── CollationBuilder.php
│ ├── ColumnDefinitionBuilder.php
│ ├── ColumnListBuilder.php
│ ├── ColumnReferenceBuilder.php
│ ├── ColumnTypeBracketExpressionBuilder.php
│ ├── ColumnTypeBuilder.php
│ ├── ConstantBuilder.php
│ ├── ConstraintBuilder.php
│ ├── CreateBuilder.php
│ ├── CreateStatementBuilder.php
│ ├── CreateTableBuilder.php
│ ├── CreateTableDefinitionBuilder.php
│ ├── CreateTableOptionsBuilder.php
│ ├── CreateTableSelectOptionBuilder.php
│ ├── DataTypeBuilder.php
│ ├── DatabaseBuilder.php
│ ├── DeleteBuilder.php
│ ├── DeleteStatementBuilder.php
│ ├── DirectionBuilder.php
│ ├── EngineBuilder.php
│ ├── ForeignKeyBuilder.php
│ ├── ForeignRefBuilder.php
│ ├── FromBuilder.php
│ ├── FunctionBuilder.php
│ ├── GroupByBuilder.php
│ ├── InListBuilder.php
│ ├── IndexColumnBuilder.php
│ ├── IndexParserBuilder.php
│ ├── IndexSizeBuilder.php
│ ├── IndexTypeBuilder.php
│ ├── InsertBuilder.php
│ ├── InsertStatementBuilder.php
│ ├── JoinBuilder.php
│ ├── LikeBuilder.php
│ ├── LikeExpressionBuilder.php
│ ├── LimitBuilder.php
│ ├── OperatorBuilder.php
│ ├── OrderByAliasBuilder.php
│ ├── OrderByBuilder.php
│ ├── PositionBuilder.php
│ ├── PrimaryKeyBuilder.php
│ ├── ProcedureBuilder.php
│ ├── RecordBuilder.php
│ ├── RefClauseBuilder.php
│ ├── RefTypeBuilder.php
│ ├── ReservedBuilder.php
│ ├── SelectBracketExpressionBuilder.php
│ ├── SelectBuilder.php
│ ├── SelectExpressionBuilder.php
│ ├── SelectStatementBuilder.php
│ ├── SetBuilder.php
│ ├── SetExpressionBuilder.php
│ ├── ShowBuilder.php
│ ├── ShowStatementBuilder.php
│ ├── SubQueryBuilder.php
│ ├── SubTreeBuilder.php
│ ├── TableBracketExpressionBuilder.php
│ ├── TableBuilder.php
│ ├── TableExpressionBuilder.php
│ ├── UpdateBuilder.php
│ ├── UpdateStatementBuilder.php
│ ├── UserVariableBuilder.php
│ ├── ValuesBuilder.php
│ ├── WhereBracketExpressionBuilder.php
│ ├── WhereBuilder.php
│ └── WhereExpressionBuilder.php
├── exceptions/
│ ├── InvalidParameterException.php
│ ├── UnableToCalculatePositionException.php
│ ├── UnableToCreateSQLException.php
│ └── UnsupportedFeatureException.php
├── lexer/
│ ├── LexerSplitter.php
│ └── PHPSQLLexer.php
├── positions/
│ └── PositionCalculator.php
├── processors/
│ ├── AbstractProcessor.php
│ ├── ColumnDefinitionProcessor.php
│ ├── ColumnListProcessor.php
│ ├── CreateDefinitionProcessor.php
│ ├── CreateProcessor.php
│ ├── DefaultProcessor.php
│ ├── DeleteProcessor.php
│ ├── DescProcessor.php
│ ├── DescribeProcessor.php
│ ├── DropProcessor.php
│ ├── DuplicateProcessor.php
│ ├── ExplainProcessor.php
│ ├── ExpressionListProcessor.php
│ ├── FromProcessor.php
│ ├── GroupByProcessor.php
│ ├── HavingProcessor.php
│ ├── IndexColumnListProcessor.php
│ ├── InsertProcessor.php
│ ├── IntoProcessor.php
│ ├── LimitProcessor.php
│ ├── OrderByProcessor.php
│ ├── RecordProcessor.php
│ ├── ReferenceDefinitionProcessor.php
│ ├── RenameProcessor.php
│ ├── ReplaceProcessor.php
│ ├── SQLChunkProcessor.php
│ ├── SQLProcessor.php
│ ├── SelectExpressionProcessor.php
│ ├── SelectProcessor.php
│ ├── SetProcessor.php
│ ├── ShowProcessor.php
│ ├── TableProcessor.php
│ ├── UnionProcessor.php
│ ├── UpdateProcessor.php
│ ├── UsingProcessor.php
│ ├── ValuesProcessor.php
│ └── WhereProcessor.php
└── utils/
├── ExpressionToken.php
├── ExpressionType.php
├── PHPSQLParserConstants.php
└── PHPSQLParserUtils.php
SYMBOL INDEX (556 symbols across 120 files)
FILE: EsParser_realse.php
class EsParser (line 14) | class EsParser {
method __construct (line 48) | public function __construct($sql = false,$calcPositions = false,$es_co...
method parsesql (line 95) | public function parsesql($sql, $calcPositions = false) {
method parse (line 106) | public function parse($sql, $calcPositions = false) {
method EsBuilder (line 118) | private function EsBuilder(){
method explain (line 174) | public function explain(){
method table (line 180) | private function table($arr){
method update (line 197) | private function update($arr){
method delete (line 206) | private function delete($arr){
method getEsData (line 209) | private function getEsData($url){
method PostEs (line 236) | private function PostEs($postdata,$json=true,$token=false){
method where (line 312) | private function where($arr){
method whereext (line 327) | private function whereext($arr,$i){
method listtree (line 734) | private function listtree($arr,$aggs,$order){
method groupby (line 767) | private function groupby($arr){
method orderby (line 881) | private function orderby($arr){
method limit (line 905) | private function limit($arr){
method select (line 914) | private function select($arr){
method updateset (line 945) | private function updateset($arr){
FILE: src/library/EsCreator.php
class PHPSQLCreator (line 57) | class PHPSQLCreator {
method __construct (line 59) | public function __construct($parsed = false) {
method create (line 65) | public function create($parsed) {
method processRenameTableStatement (line 109) | protected function processRenameTableStatement($parsed) {
method processSourceAndDestTable (line 126) | protected function processSourceAndDestTable($v) {
FILE: src/library/EsParser.php
class EsParser (line 14) | class EsParser {
method __construct (line 70) | public function __construct($sql = false,$calcPositions = false,$es_co...
method parsesql (line 121) | public function parsesql($sql, $calcPositions = false) {
method setSql (line 132) | public function setSql($sql, $calcPositions = false) {
method parse (line 138) | public function parse($sql, $calcPositions = false) {
method EsBuilder (line 150) | private function EsBuilder(){
method build (line 216) | public function build(){
method explain (line 220) | public function explain(){
method scroll (line 226) | public function scroll($scrollid=''){
method table (line 242) | private function table($arr){
method insert (line 267) | private function insert($arr){
method resdata (line 281) | private function resdata($data,$value){
method update (line 298) | private function update($arr){
method delete (line 307) | private function delete($arr){
method getEsData (line 310) | private function getEsData($url){
method PostEs (line 337) | private function PostEs($postdata,$json=true,$token=false){
method where (line 470) | private function where($arr){
method whereorext (line 503) | private function whereorext($arr){
method whereorink (line 862) | private function whereorink($arr,$i){
method whereor (line 872) | private function whereor($arr,$i){
method whereext (line 930) | private function whereext($arr,$i){
method listtree (line 1876) | private function listtree($arr,$aggs,$order){
method groupby (line 1925) | private function groupby($arr){
method orderby (line 2116) | private function orderby($arr){
method limit (line 2144) | private function limit($arr){
method haveext (line 2157) | private function haveext($arr,$i){
method having (line 2674) | private function having($arr){
method select (line 2686) | private function select($arr){
method updateset (line 2733) | private function updateset($arr){
FILE: src/library/builders/AliasBuilder.php
class AliasBuilder (line 50) | class AliasBuilder {
method hasAlias (line 52) | public function hasAlias($parsed) {
method build (line 56) | public function build($parsed) {
FILE: src/library/builders/CharacterSetBuilder.php
class CharacterSetBuilder (line 57) | class CharacterSetBuilder {
method buildConstant (line 59) | protected function buildConstant($parsed) {
method buildOperator (line 64) | protected function buildOperator($parsed) {
method buildReserved (line 69) | protected function buildReserved($parsed) {
method build (line 74) | public function build($parsed) {
FILE: src/library/builders/CheckBuilder.php
class CheckBuilder (line 54) | class CheckBuilder {
method buildSelectBracketExpression (line 56) | protected function buildSelectBracketExpression($parsed) {
method buildReserved (line 61) | protected function buildReserved($parsed) {
method build (line 66) | public function build($parsed) {
FILE: src/library/builders/CollationBuilder.php
class CollationBuilder (line 56) | class CollationBuilder {
method buildOperator (line 58) | protected function buildOperator($parsed) {
method buildConstant (line 63) | protected function buildConstant($parsed) {
method buildReserved (line 68) | protected function buildReserved($parsed) {
method build (line 73) | public function build($parsed) {
FILE: src/library/builders/ColumnDefinitionBuilder.php
class ColumnDefinitionBuilder (line 54) | class ColumnDefinitionBuilder {
method buildColRef (line 56) | protected function buildColRef($parsed) {
method buildColumnType (line 61) | protected function buildColumnType($parsed) {
method build (line 66) | public function build($parsed) {
FILE: src/library/builders/ColumnListBuilder.php
class ColumnListBuilder (line 53) | class ColumnListBuilder {
method buildIndexColumn (line 55) | protected function buildIndexColumn($parsed) {
method build (line 60) | public function build($parsed) {
FILE: src/library/builders/ColumnReferenceBuilder.php
class ColumnReferenceBuilder (line 53) | class ColumnReferenceBuilder {
method buildDirection (line 55) | protected function buildDirection($parsed) {
method buildAlias (line 60) | protected function buildAlias($parsed) {
method build (line 65) | public function build($parsed) {
FILE: src/library/builders/ColumnTypeBracketExpressionBuilder.php
class ColumnTypeBracketExpressionBuilder (line 52) | class ColumnTypeBracketExpressionBuilder {
method buildSubTree (line 54) | protected function buildSubTree($parsed, $delim) {
method build (line 59) | public function build($parsed) {
FILE: src/library/builders/ColumnTypeBuilder.php
class ColumnTypeBuilder (line 55) | class ColumnTypeBuilder {
method buildColumnTypeBracketExpression (line 57) | protected function buildColumnTypeBracketExpression($parsed) {
method buildReserved (line 62) | protected function buildReserved($parsed) {
method buildDataType (line 67) | protected function buildDataType($parsed) {
method build (line 72) | public function build($parsed) {
FILE: src/library/builders/ConstantBuilder.php
class ConstantBuilder (line 53) | class ConstantBuilder {
method buildAlias (line 55) | protected function buildAlias($parsed) {
method build (line 60) | public function build($parsed) {
FILE: src/library/builders/ConstraintBuilder.php
class ConstraintBuilder (line 53) | class ConstraintBuilder {
method buildConstant (line 55) | protected function buildConstant($parsed) {
method build (line 60) | public function build($parsed) {
FILE: src/library/builders/CreateBuilder.php
class CreateBuilder (line 54) | class CreateBuilder {
method buildCreateTable (line 56) | protected function buildCreateTable($parsed) {
method buildSubTree (line 61) | protected function buildSubTree($parsed) {
method build (line 66) | public function build($parsed) {
FILE: src/library/builders/CreateStatementBuilder.php
class CreateStatementBuilder (line 54) | class CreateStatementBuilder {
method buildLIKE (line 56) | protected function buildLIKE($parsed) {
method buildSelectStatement (line 61) | protected function buildSelectStatement($parsed) {
method buildCREATE (line 66) | protected function buildCREATE($parsed) {
method build (line 71) | public function build($parsed) {
FILE: src/library/builders/CreateTableBuilder.php
class CreateTableBuilder (line 55) | class CreateTableBuilder {
method buildCreateTableDefinition (line 57) | protected function buildCreateTableDefinition($parsed) {
method buildCreateTableOptions (line 62) | protected function buildCreateTableOptions($parsed) {
method buildCreateTableSelectOption (line 67) | protected function buildCreateTableSelectOption($parsed) {
method build (line 72) | public function build($parsed) {
FILE: src/library/builders/CreateTableDefinitionBuilder.php
class CreateTableDefinitionBuilder (line 52) | class CreateTableDefinitionBuilder {
method buildTableBracketExpression (line 54) | protected function buildTableBracketExpression($parsed) {
method build (line 59) | public function build($parsed) {
FILE: src/library/builders/CreateTableOptionsBuilder.php
class CreateTableOptionsBuilder (line 55) | class CreateTableOptionsBuilder {
method buildExpression (line 57) | protected function buildExpression($parsed) {
method buildCharacterSet (line 62) | protected function buildCharacterSet($parsed) {
method buildCollation (line 67) | protected function buildCollation($parsed) {
method getDelimiter (line 79) | protected function getDelimiter($parsed) {
method build (line 83) | public function build($parsed) {
FILE: src/library/builders/CreateTableSelectOptionBuilder.php
class CreateTableSelectOptionBuilder (line 50) | class CreateTableSelectOptionBuilder {
method build (line 52) | public function build($parsed) {
FILE: src/library/builders/DataTypeBuilder.php
class DataTypeBuilder (line 52) | class DataTypeBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/DatabaseBuilder.php
class DatabaseBuilder (line 52) | class DatabaseBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/DeleteBuilder.php
class DeleteBuilder (line 50) | class DeleteBuilder {
method build (line 52) | public function build($parsed) {
FILE: src/library/builders/DeleteStatementBuilder.php
class DeleteStatementBuilder (line 54) | class DeleteStatementBuilder {
method buildWHERE (line 56) | protected function buildWHERE($parsed) {
method buildFROM (line 61) | protected function buildFROM($parsed) {
method buildDELETE (line 66) | protected function buildDELETE($parsed) {
method processDeleteStatement (line 71) | public function processDeleteStatement($parsed) {
FILE: src/library/builders/DirectionBuilder.php
class DirectionBuilder (line 50) | class DirectionBuilder {
method build (line 52) | public function build($parsed) {
FILE: src/library/builders/EngineBuilder.php
class EngineBuilder (line 52) | class EngineBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/ForeignKeyBuilder.php
class ForeignKeyBuilder (line 57) | class ForeignKeyBuilder {
method buildConstant (line 59) | protected function buildConstant($parsed) {
method buildColumnList (line 64) | protected function buildColumnList($parsed) {
method buildReserved (line 69) | protected function buildReserved($parsed) {
method buildForeignRef (line 74) | protected function buildForeignRef($parsed) {
method build (line 79) | public function build($parsed) {
FILE: src/library/builders/ForeignRefBuilder.php
class ForeignRefBuilder (line 57) | class ForeignRefBuilder {
method buildTable (line 59) | protected function buildTable($parsed) {
method buildColumnList (line 64) | protected function buildColumnList($parsed) {
method buildReserved (line 69) | protected function buildReserved($parsed) {
method build (line 74) | public function build($parsed) {
FILE: src/library/builders/FromBuilder.php
class FromBuilder (line 55) | class FromBuilder {
method buildTable (line 57) | protected function buildTable($parsed, $key) {
method buildTableExpression (line 62) | protected function buildTableExpression($parsed, $key) {
method buildSubQuery (line 67) | protected function buildSubQuery($parsed, $key) {
method build (line 72) | public function build($parsed) {
FILE: src/library/builders/FunctionBuilder.php
class FunctionBuilder (line 61) | class FunctionBuilder {
method buildDirection (line 63) | protected function buildDirection($parsed) {
method buildAlias (line 68) | protected function buildAlias($parsed) {
method buildColRef (line 73) | protected function buildColRef($parsed) {
method buildConstant (line 78) | protected function buildConstant($parsed) {
method buildReserved (line 83) | protected function buildReserved($parsed) {
method isReserved (line 88) | protected function isReserved($parsed) {
method buildSelectExpression (line 93) | protected function buildSelectExpression($parsed) {
method buildSelectBracketExpression (line 98) | protected function buildSelectBracketExpression($parsed) {
method build (line 103) | public function build($parsed) {
FILE: src/library/builders/GroupByBuilder.php
class GroupByBuilder (line 55) | class GroupByBuilder {
method buildColRef (line 57) | protected function buildColRef($parsed) {
method buildPosition (line 62) | protected function buildPosition($parsed) {
method buildFunction (line 67) | protected function buildFunction($parsed) {
method build (line 72) | public function build($parsed) {
FILE: src/library/builders/InListBuilder.php
class InListBuilder (line 53) | class InListBuilder {
method buildSubTree (line 55) | protected function buildSubTree($parsed, $delim) {
method build (line 60) | public function build($parsed) {
FILE: src/library/builders/IndexColumnBuilder.php
class IndexColumnBuilder (line 53) | class IndexColumnBuilder {
method buildLength (line 55) | protected function buildLength($parsed) {
method buildDirection (line 59) | protected function buildDirection($parsed) {
method build (line 63) | public function build($parsed) {
FILE: src/library/builders/IndexParserBuilder.php
class IndexParserBuilder (line 58) | class IndexParserBuilder {
method buildReserved (line 60) | protected function buildReserved($parsed) {
method buildConstant (line 65) | protected function buildConstant($parsed) {
method build (line 70) | public function build($parsed) {
FILE: src/library/builders/IndexSizeBuilder.php
class IndexSizeBuilder (line 58) | class IndexSizeBuilder {
method buildReserved (line 60) | protected function buildReserved($parsed) {
method buildConstant (line 65) | protected function buildConstant($parsed) {
method build (line 70) | public function build($parsed) {
FILE: src/library/builders/IndexTypeBuilder.php
class IndexTypeBuilder (line 58) | class IndexTypeBuilder {
method buildReserved (line 60) | protected function buildReserved($parsed) {
method build (line 65) | public function build($parsed) {
FILE: src/library/builders/InsertBuilder.php
class InsertBuilder (line 53) | class InsertBuilder {
method buildColRef (line 55) | protected function buildColRef($parsed) {
method build (line 60) | public function build($parsed) {
FILE: src/library/builders/InsertStatementBuilder.php
class InsertStatementBuilder (line 53) | class InsertStatementBuilder {
method buildVALUES (line 55) | protected function buildVALUES($parsed) {
method buildINSERT (line 60) | protected function buildINSERT($parsed) {
method build (line 65) | public function build($parsed) {
FILE: src/library/builders/JoinBuilder.php
class JoinBuilder (line 52) | class JoinBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/LikeBuilder.php
class LikeBuilder (line 53) | class LikeBuilder {
method buildTable (line 55) | protected function buildTable($parsed, $index) {
method build (line 60) | public function build($parsed) {
FILE: src/library/builders/LikeExpressionBuilder.php
class LikeExpressionBuilder (line 56) | class LikeExpressionBuilder {
method buildTable (line 58) | protected function buildTable($parsed, $index) {
method buildReserved (line 63) | protected function buildReserved($parsed) {
method build (line 68) | public function build($parsed) {
FILE: src/library/builders/LimitBuilder.php
class LimitBuilder (line 52) | class LimitBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/OperatorBuilder.php
class OperatorBuilder (line 52) | class OperatorBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/OrderByAliasBuilder.php
class OrderByAliasBuilder (line 53) | class OrderByAliasBuilder {
method buildDirection (line 55) | protected function buildDirection($parsed) {
method build (line 60) | public function build($parsed) {
FILE: src/library/builders/OrderByBuilder.php
class OrderByBuilder (line 54) | class OrderByBuilder {
method buildFunction (line 56) | protected function buildFunction($parsed) {
method buildColRef (line 61) | protected function buildColRef($parsed) {
method buildOrderByAlias (line 66) | protected function buildOrderByAlias($parsed) {
method build (line 71) | public function build($parsed) {
FILE: src/library/builders/PositionBuilder.php
class PositionBuilder (line 52) | class PositionBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/PrimaryKeyBuilder.php
class PrimaryKeyBuilder (line 59) | class PrimaryKeyBuilder {
method buildColumnList (line 61) | protected function buildColumnList($parsed) {
method buildConstraint (line 66) | protected function buildConstraint($parsed) {
method buildReserved (line 71) | protected function buildReserved($parsed) {
method buildIndexType (line 76) | protected function buildIndexType($parsed) {
method buildIndexSize (line 81) | protected function buildIndexSize($parsed) {
method buildIndexParser (line 86) | protected function buildIndexParser($parsed) {
method build (line 91) | public function build($parsed) {
FILE: src/library/builders/ProcedureBuilder.php
class ProcedureBuilder (line 52) | class ProcedureBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/RecordBuilder.php
class RecordBuilder (line 56) | class RecordBuilder {
method buildOperator (line 58) | protected function buildOperator($parsed) {
method buildFunction (line 63) | protected function buildFunction($parsed) {
method buildConstant (line 68) | protected function buildConstant($parsed) {
method build (line 73) | public function build($parsed) {
FILE: src/library/builders/RefClauseBuilder.php
class RefClauseBuilder (line 55) | class RefClauseBuilder {
method buildColRef (line 57) | protected function buildColRef($parsed) {
method buildOperator (line 62) | protected function buildOperator($parsed) {
method buildConstant (line 67) | protected function buildConstant($parsed) {
method build (line 72) | public function build($parsed) {
FILE: src/library/builders/RefTypeBuilder.php
class RefTypeBuilder (line 52) | class RefTypeBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/ReservedBuilder.php
class ReservedBuilder (line 52) | class ReservedBuilder {
method isReserved (line 54) | public function isReserved($parsed) {
method build (line 58) | public function build($parsed) {
FILE: src/library/builders/SelectBracketExpressionBuilder.php
class SelectBracketExpressionBuilder (line 52) | class SelectBracketExpressionBuilder {
method buildSubTree (line 54) | protected function buildSubTree($parsed, $delim) {
method build (line 59) | public function build($parsed) {
FILE: src/library/builders/SelectBuilder.php
class SelectBuilder (line 56) | class SelectBuilder {
method buildConstant (line 58) | protected function buildConstant($parsed) {
method buildFunction (line 63) | protected function buildFunction($parsed) {
method buildSelectExpression (line 68) | protected function buildSelectExpression($parsed) {
method buildSelectBracketExpression (line 73) | protected function buildSelectBracketExpression($parsed) {
method buildColRef (line 78) | protected function buildColRef($parsed) {
method buildReserved (line 83) | protected function buildReserved($parsed) {
method getDelimiter (line 94) | protected function getDelimiter($parsed) {
method build (line 98) | public function build($parsed) {
FILE: src/library/builders/SelectExpressionBuilder.php
class SelectExpressionBuilder (line 54) | class SelectExpressionBuilder {
method buildSubTree (line 56) | protected function buildSubTree($parsed, $delim) {
method buildAlias (line 61) | protected function buildAlias($parsed) {
method build (line 66) | public function build($parsed) {
FILE: src/library/builders/SelectStatementBuilder.php
class SelectStatementBuilder (line 57) | class SelectStatementBuilder {
method buildSELECT (line 59) | protected function buildSELECT($parsed) {
method buildFROM (line 64) | protected function buildFROM($parsed) {
method buildWHERE (line 69) | protected function buildWHERE($parsed) {
method buildGROUP (line 74) | protected function buildGROUP($parsed) {
method buildORDER (line 79) | protected function buildORDER($parsed) {
method buildLIMIT (line 84) | protected function buildLIMIT($parsed) {
method build (line 89) | public function build($parsed) {
FILE: src/library/builders/SetBuilder.php
class SetBuilder (line 53) | class SetBuilder {
method buildSetExpression (line 55) | protected function buildSetExpression($parsed) {
method build (line 60) | public function build($parsed) {
FILE: src/library/builders/SetExpressionBuilder.php
class SetExpressionBuilder (line 57) | class SetExpressionBuilder {
method buildColRef (line 59) | protected function buildColRef($parsed) {
method buildConstant (line 64) | protected function buildConstant($parsed) {
method buildOperator (line 69) | protected function buildOperator($parsed) {
method buildFunction (line 74) | protected function buildFunction($parsed) {
method build (line 79) | public function build($parsed) {
FILE: src/library/builders/ShowBuilder.php
class ShowBuilder (line 59) | class ShowBuilder {
method buildTable (line 61) | protected function buildTable($parsed, $delim) {
method buildFunction (line 66) | protected function buildFunction($parsed) {
method buildProcedure (line 71) | protected function buildProcedure($parsed) {
method buildDatabase (line 76) | protected function buildDatabase($parsed) {
method buildEngine (line 81) | protected function buildEngine($parsed) {
method buildConstant (line 86) | protected function buildConstant($parsed) {
method buildReserved (line 91) | protected function buildReserved($parsed) {
method build (line 96) | public function build($parsed) {
FILE: src/library/builders/ShowStatementBuilder.php
class ShowStatementBuilder (line 53) | class ShowStatementBuilder {
method buildWHERE (line 55) | protected function buildWHERE($parsed) {
method buildSHOW (line 60) | protected function buildSHOW($parsed) {
method build (line 65) | public function build($parsed) {
FILE: src/library/builders/SubQueryBuilder.php
class SubQueryBuilder (line 57) | class SubQueryBuilder {
method buildRefClause (line 59) | protected function buildRefClause($parsed) {
method buildRefType (line 64) | protected function buildRefType($parsed) {
method buildJoin (line 69) | protected function buildJoin($parsed) {
method buildAlias (line 74) | protected function buildAlias($parsed) {
method buildSelectStatement (line 79) | protected function buildSelectStatement($parsed) {
method build (line 84) | public function build($parsed, $index = 0) {
FILE: src/library/builders/SubTreeBuilder.php
class SubTreeBuilder (line 60) | class SubTreeBuilder {
method buildColRef (line 62) | protected function buildColRef($parsed) {
method buildFunction (line 67) | protected function buildFunction($parsed) {
method buildOperator (line 72) | protected function buildOperator($parsed) {
method buildConstant (line 77) | protected function buildConstant($parsed) {
method buildReserved (line 82) | protected function buildReserved($parsed) {
method buildSubQuery (line 87) | protected function buildSubQuery($parsed) {
method buildSelectBracketExpression (line 92) | protected function buildSelectBracketExpression($parsed) {
method build (line 97) | public function build($parsed, $delim = " ") {
FILE: src/library/builders/TableBracketExpressionBuilder.php
class TableBracketExpressionBuilder (line 58) | class TableBracketExpressionBuilder {
method buildColDef (line 60) | protected function buildColDef($parsed) {
method buildPrimaryKey (line 65) | protected function buildPrimaryKey($parsed) {
method buildForeignKey (line 70) | protected function buildForeignKey($parsed) {
method buildCheck (line 75) | protected function buildCheck($parsed) {
method buildLikeExpression (line 80) | protected function buildLikeExpression($parsed) {
method build (line 85) | public function build($parsed) {
FILE: src/library/builders/TableBuilder.php
class TableBuilder (line 56) | class TableBuilder {
method buildAlias (line 58) | protected function buildAlias($parsed) {
method buildJoin (line 63) | protected function buildJoin($parsed) {
method buildRefType (line 68) | protected function buildRefType($parsed) {
method buildRefClause (line 73) | protected function buildRefClause($parsed) {
method build (line 78) | public function build($parsed, $index) {
FILE: src/library/builders/TableExpressionBuilder.php
class TableExpressionBuilder (line 57) | class TableExpressionBuilder {
method buildFROM (line 59) | protected function buildFROM($parsed) {
method buildAlias (line 64) | protected function buildAlias($parsed) {
method buildJoin (line 69) | protected function buildJoin($parsed) {
method buildRefType (line 74) | protected function buildRefType($parsed) {
method buildRefClause (line 79) | protected function buildRefClause($parsed) {
method build (line 84) | public function build($parsed, $index) {
FILE: src/library/builders/UpdateBuilder.php
class UpdateBuilder (line 50) | class UpdateBuilder {
method build (line 52) | public function build($parsed) {
FILE: src/library/builders/UpdateStatementBuilder.php
class UpdateStatementBuilder (line 54) | class UpdateStatementBuilder {
method buildWHERE (line 56) | protected function buildWHERE($parsed) {
method buildSET (line 61) | protected function buildSET($parsed) {
method buildUPDATE (line 66) | protected function buildUPDATE($parsed) {
method build (line 71) | public function build($parsed) {
FILE: src/library/builders/UserVariableBuilder.php
class UserVariableBuilder (line 52) | class UserVariableBuilder {
method build (line 54) | public function build($parsed) {
FILE: src/library/builders/ValuesBuilder.php
class ValuesBuilder (line 53) | class ValuesBuilder {
method buildRecord (line 55) | protected function buildRecord($parsed) {
method build (line 60) | public function build($parsed) {
FILE: src/library/builders/WhereBracketExpressionBuilder.php
class WhereBracketExpressionBuilder (line 61) | class WhereBracketExpressionBuilder {
method buildColRef (line 63) | protected function buildColRef($parsed) {
method buildConstant (line 68) | protected function buildConstant($parsed) {
method buildOperator (line 73) | protected function buildOperator($parsed) {
method buildFunction (line 78) | protected function buildFunction($parsed) {
method buildInList (line 83) | protected function buildInList($parsed) {
method buildWhereExpression (line 88) | protected function buildWhereExpression($parsed) {
method buildUserVariable (line 93) | protected function buildUserVariable($parsed) {
method build (line 98) | public function build($parsed) {
FILE: src/library/builders/WhereBuilder.php
class WhereBuilder (line 62) | class WhereBuilder {
method buildColRef (line 64) | protected function buildColRef($parsed) {
method buildConstant (line 69) | protected function buildConstant($parsed) {
method buildOperator (line 74) | protected function buildOperator($parsed) {
method buildFunction (line 79) | protected function buildFunction($parsed) {
method buildSubQuery (line 84) | protected function buildSubQuery($parsed) {
method buildInList (line 89) | protected function buildInList($parsed) {
method buildWhereExpression (line 94) | protected function buildWhereExpression($parsed) {
method buildWhereBracketExpression (line 99) | protected function buildWhereBracketExpression($parsed) {
method buildUserVariable (line 104) | protected function buildUserVariable($parsed) {
method build (line 109) | public function build($parsed) {
FILE: src/library/builders/WhereExpressionBuilder.php
class WhereExpressionBuilder (line 61) | class WhereExpressionBuilder {
method buildColRef (line 63) | protected function buildColRef($parsed) {
method buildConstant (line 68) | protected function buildConstant($parsed) {
method buildOperator (line 73) | protected function buildOperator($parsed) {
method buildFunction (line 78) | protected function buildFunction($parsed) {
method buildInList (line 83) | protected function buildInList($parsed) {
method buildWhereExpression (line 88) | protected function buildWhereExpression($parsed) {
method buildWhereBracketExpression (line 93) | protected function buildWhereBracketExpression($parsed) {
method buildUserVariable (line 98) | protected function buildUserVariable($parsed) {
method build (line 103) | public function build($parsed) {
FILE: src/library/exceptions/InvalidParameterException.php
class InvalidParameterException (line 41) | class InvalidParameterException extends InvalidArgumentException {
method __construct (line 45) | public function __construct($argument) {
method getArgument (line 50) | public function getArgument() {
FILE: src/library/exceptions/UnableToCalculatePositionException.php
class UnableToCalculatePositionException (line 42) | class UnableToCalculatePositionException extends Exception {
method __construct (line 47) | public function __construct($needle, $haystack) {
method getNeedle (line 53) | public function getNeedle() {
method getHaystack (line 57) | public function getHaystack() {
FILE: src/library/exceptions/UnableToCreateSQLException.php
class UnableToCreateSQLException (line 43) | class UnableToCreateSQLException extends Exception {
method __construct (line 50) | public function __construct($part, $partkey, $entry, $entrykey) {
method getEntry (line 58) | public function getEntry() {
method getEntryKey (line 62) | public function getEntryKey() {
method getSQLPart (line 66) | public function getSQLPart() {
method getSQLPartKey (line 70) | public function getSQLPartKey() {
FILE: src/library/exceptions/UnsupportedFeatureException.php
class UnsupportedFeatureException (line 43) | class UnsupportedFeatureException extends Exception {
method __construct (line 47) | public function __construct($key) {
method getKey (line 52) | public function getKey() {
FILE: src/library/lexer/LexerSplitter.php
class LexerSplitter (line 52) | class LexerSplitter {
method __construct (line 65) | public function __construct() {
method getMaxLengthOfSplitter (line 78) | public function getMaxLengthOfSplitter() {
method isSplitter (line 90) | public function isSplitter($token) {
FILE: src/library/lexer/PHPSQLLexer.php
class PHPSQLLexer (line 54) | class PHPSQLLexer {
method __construct (line 63) | public function __construct() {
method endsWith (line 75) | protected function endsWith($haystack, $needle) {
method split (line 83) | public function split($sql) {
method concatUserDefinedVariables (line 131) | protected function concatUserDefinedVariables($tokens) {
method concatComments (line 163) | protected function concatComments($tokens) {
method isBacktick (line 206) | protected function isBacktick($token) {
method balanceBackticks (line 210) | protected function balanceBackticks($tokens) {
method balanceCharacter (line 234) | protected function balanceCharacter($tokens, $idx, $char) {
method concatColReferences (line 266) | protected function concatColReferences($tokens) {
method concatEscapeSequences (line 315) | protected function concatEscapeSequences($tokens) {
method balanceParenthesis (line 332) | protected function balanceParenthesis($tokens) {
FILE: src/library/positions/PositionCalculator.php
class PositionCalculator (line 44) | class PositionCalculator {
method _printPos (line 50) | private function _printPos($text, $sql, $charPos, $key, $parsed, $back...
method setPositionsWithinSQL (line 67) | public function setPositionsWithinSQL($sql, $parsed) {
method findPositionWithinString (line 74) | private function findPositionWithinString($sql, $value, $expr_type) {
method lookForBaseExpression (line 132) | private function lookForBaseExpression($sql, &$charPos, &$parsed, $key...
FILE: src/library/processors/AbstractProcessor.php
class AbstractProcessor (line 43) | abstract class AbstractProcessor {
method process (line 49) | public abstract function process($tokens);
method splitSQLIntoTokens (line 55) | public function splitSQLIntoTokens($sql) {
method revokeQuotation (line 63) | protected function revokeQuotation($sql) {
method removeParenthesisFromStart (line 88) | protected function removeParenthesisFromStart($token) {
method getVariableType (line 128) | protected function getVariableType($expression) {
method isCommaToken (line 151) | protected function isCommaToken($token) {
method isWhitespaceToken (line 155) | protected function isWhitespaceToken($token) {
method isCommentToken (line 159) | protected function isCommentToken($token) {
method isColumnReference (line 164) | protected function isColumnReference($out) {
method isReserved (line 168) | protected function isReserved($out) {
method isConstant (line 172) | protected function isConstant($out) {
method isAggregateFunction (line 176) | protected function isAggregateFunction($out) {
method isFunction (line 180) | protected function isFunction($out) {
method isExpression (line 184) | protected function isExpression($out) {
method isBracketExpression (line 188) | protected function isBracketExpression($out) {
method isSubQuery (line 192) | protected function isSubQuery($out) {
method toArray (line 199) | public function toArray($tokenList) {
method array_insert_after (line 207) | protected function array_insert_after($array, $key, $entry) {
FILE: src/library/processors/ColumnDefinitionProcessor.php
class ColumnDefinitionProcessor (line 45) | class ColumnDefinitionProcessor extends AbstractProcessor {
method processExpressionList (line 47) | protected function processExpressionList($parsed) {
method processReferenceDefinition (line 52) | protected function processReferenceDefinition($parsed) {
method removeComma (line 57) | protected function removeComma($tokens) {
method buildColDef (line 67) | protected function buildColDef($expr, $base_expr, $options, $refs, $ke...
method process (line 84) | public function process($tokens) {
FILE: src/library/processors/ColumnListProcessor.php
class ColumnListProcessor (line 43) | class ColumnListProcessor extends AbstractProcessor {
method process (line 45) | public function process($tokens) {
FILE: src/library/processors/CreateDefinitionProcessor.php
class CreateDefinitionProcessor (line 46) | class CreateDefinitionProcessor extends AbstractProcessor {
method correctExpressionType (line 48) | protected function correctExpressionType(&$expr) {
method process (line 75) | public function process($tokens) {
FILE: src/library/processors/CreateProcessor.php
class CreateProcessor (line 43) | class CreateProcessor extends AbstractProcessor {
method process (line 45) | public function process($tokens) {
FILE: src/library/processors/DefaultProcessor.php
class DefaultProcessor (line 44) | class DefaultProcessor extends AbstractProcessor {
method process (line 46) | public function process($sql) {
FILE: src/library/processors/DeleteProcessor.php
class DeleteProcessor (line 42) | class DeleteProcessor extends AbstractProcessor {
method process (line 44) | public function process($tokens) {
FILE: src/library/processors/DescProcessor.php
class DescProcessor (line 42) | class DescProcessor extends ExplainProcessor {
method isStatement (line 44) | protected function isStatement($keys, $needle = "DESC") {
FILE: src/library/processors/DescribeProcessor.php
class DescribeProcessor (line 42) | class DescribeProcessor extends ExplainProcessor {
method isStatement (line 44) | protected function isStatement($keys, $needle = "DESCRIBE") {
FILE: src/library/processors/DropProcessor.php
class DropProcessor (line 44) | class DropProcessor extends AbstractProcessor {
method process (line 48) | public function process($tokenList) {
FILE: src/library/processors/DuplicateProcessor.php
class DuplicateProcessor (line 42) | class DuplicateProcessor extends SetProcessor {
method process (line 44) | public function process($tokens,$isUpdate = false) {
FILE: src/library/processors/ExplainProcessor.php
class ExplainProcessor (line 43) | class ExplainProcessor extends AbstractProcessor {
method isStatement (line 45) | protected function isStatement($keys, $needle = "EXPLAIN") {
method process (line 54) | public function process($tokens, $keys = array()) {
FILE: src/library/processors/ExpressionListProcessor.php
class ExpressionListProcessor (line 45) | class ExpressionListProcessor extends AbstractProcessor {
method process (line 47) | public function process($tokens) {
FILE: src/library/processors/FromProcessor.php
class FromProcessor (line 45) | class FromProcessor extends AbstractProcessor {
method initParseInfo (line 47) | protected function initParseInfo($parseInfo = false) {
method processFromExpression (line 59) | protected function processFromExpression(&$parseInfo) {
method process (line 108) | public function process($tokens) {
FILE: src/library/processors/GroupByProcessor.php
class GroupByProcessor (line 42) | class GroupByProcessor extends OrderByProcessor {
method process (line 44) | public function process($tokens, $select = array()) {
FILE: src/library/processors/HavingProcessor.php
class HavingProcessor (line 42) | class HavingProcessor extends ExpressionListProcessor {
FILE: src/library/processors/IndexColumnListProcessor.php
class IndexColumnListProcessor (line 43) | class IndexColumnListProcessor extends AbstractProcessor {
method initExpression (line 45) | protected function initExpression() {
method process (line 49) | public function process($sql) {
FILE: src/library/processors/InsertProcessor.php
class InsertProcessor (line 44) | class InsertProcessor extends AbstractProcessor {
method process (line 46) | public function process($tokenList, $token_category = 'INSERT') {
FILE: src/library/processors/IntoProcessor.php
class IntoProcessor (line 42) | class IntoProcessor extends AbstractProcessor {
method process (line 48) | public function process($tokenList) {
FILE: src/library/processors/LimitProcessor.php
class LimitProcessor (line 42) | class LimitProcessor extends AbstractProcessor {
method process (line 44) | public function process($tokens) {
FILE: src/library/processors/OrderByProcessor.php
class OrderByProcessor (line 44) | class OrderByProcessor extends AbstractProcessor {
method __construct (line 48) | public function __construct() {
method initParseInfo (line 52) | protected function initParseInfo() {
method processOrderExpression (line 56) | protected function processOrderExpression(&$parseInfo, $select) {
method process (line 97) | public function process($tokens, $select = array()) {
FILE: src/library/processors/RecordProcessor.php
class RecordProcessor (line 43) | class RecordProcessor extends AbstractProcessor {
method __construct (line 47) | public function __construct() {
method process (line 51) | public function process($unparsed) {
FILE: src/library/processors/ReferenceDefinitionProcessor.php
class ReferenceDefinitionProcessor (line 43) | class ReferenceDefinitionProcessor extends AbstractProcessor {
method buildReferenceDef (line 45) | protected function buildReferenceDef($expr, $base_expr, $key) {
method process (line 51) | public function process($tokens) {
FILE: src/library/processors/RenameProcessor.php
class RenameProcessor (line 44) | class RenameProcessor extends AbstractProcessor {
method process (line 46) | public function process($tokenList) {
FILE: src/library/processors/ReplaceProcessor.php
class ReplaceProcessor (line 42) | class ReplaceProcessor extends InsertProcessor {
method process (line 44) | public function process($tokenList,$token_category = 'REPLACE') {
FILE: src/library/processors/SQLChunkProcessor.php
class SQLChunkProcessor (line 69) | class SQLChunkProcessor extends AbstractProcessor {
method moveLIKE (line 71) | protected function moveLIKE(&$out) {
method process (line 79) | public function process($out) {
FILE: src/library/processors/SQLProcessor.php
class SQLProcessor (line 43) | class SQLProcessor extends SQLChunkProcessor {
method process (line 49) | public function process($tokens) {
FILE: src/library/processors/SelectExpressionProcessor.php
class SelectExpressionProcessor (line 44) | class SelectExpressionProcessor extends AbstractProcessor {
method __construct (line 48) | public function __construct() {
method process (line 57) | public function process($expression) {
FILE: src/library/processors/SelectProcessor.php
class SelectProcessor (line 42) | class SelectProcessor extends SelectExpressionProcessor {
method process (line 44) | public function process($tokens) {
FILE: src/library/processors/SetProcessor.php
class SetProcessor (line 44) | class SetProcessor extends AbstractProcessor {
method __construct (line 48) | public function __construct() {
method getAssignment (line 56) | protected function getAssignment($base_expr) {
method process (line 62) | public function process($tokens, $isUpdate = false) {
FILE: src/library/processors/ShowProcessor.php
class ShowProcessor (line 45) | class ShowProcessor extends AbstractProcessor {
method __construct (line 49) | public function __construct() {
method process (line 53) | public function process($tokens) {
FILE: src/library/processors/TableProcessor.php
class TableProcessor (line 44) | class TableProcessor extends AbstractProcessor {
method getReservedType (line 46) | protected function getReservedType($token) {
method getConstantType (line 50) | protected function getConstantType($token) {
method getOperatorType (line 54) | protected function getOperatorType($token) {
method clear (line 58) | protected function clear(&$expr, &$base_expr, &$category) {
method process (line 64) | public function process($tokens) {
FILE: src/library/processors/UnionProcessor.php
class UnionProcessor (line 45) | class UnionProcessor extends AbstractProcessor {
method isUnion (line 47) | public function isUnion($queries) {
method processMySQLUnion (line 67) | protected function processMySQLUnion($queries) {
method process (line 99) | public function process($inputArray) {
FILE: src/library/processors/UpdateProcessor.php
class UpdateProcessor (line 42) | class UpdateProcessor extends FromProcessor {
FILE: src/library/processors/UsingProcessor.php
class UsingProcessor (line 42) | class UsingProcessor extends FromProcessor {
FILE: src/library/processors/ValuesProcessor.php
class ValuesProcessor (line 44) | class ValuesProcessor extends AbstractProcessor {
method __construct (line 48) | public function __construct() {
method process (line 52) | public function process($tokens) {
FILE: src/library/processors/WhereProcessor.php
class WhereProcessor (line 42) | class WhereProcessor extends ExpressionListProcessor {
FILE: src/library/utils/ExpressionToken.php
class ExpressionToken (line 5) | class ExpressionToken {
method __construct (line 16) | public function __construct($key = "", $token = "") {
method addToken (line 28) | public function addToken($string) {
method isEnclosedWithinParenthesis (line 32) | public function isEnclosedWithinParenthesis() {
method setSubTree (line 36) | public function setSubTree($tree) {
method getSubTree (line 40) | public function getSubTree() {
method getUpper (line 44) | public function getUpper($idx = false) {
method getTrim (line 48) | public function getTrim($idx = false) {
method getToken (line 52) | public function getToken($idx = false) {
method setNoQuotes (line 56) | public function setNoQuotes($token, $qchars = '`') {
method setTokenType (line 60) | public function setTokenType($type) {
method endsWith (line 64) | public function endsWith($needle) {
method isWhitespaceToken (line 74) | public function isWhitespaceToken() {
method isCommaToken (line 78) | public function isCommaToken() {
method isVariableToken (line 82) | public function isVariableToken() {
method isSubQueryToken (line 86) | public function isSubQueryToken() {
method isExpression (line 90) | public function isExpression() {
method isBracketExpression (line 94) | public function isBracketExpression() {
method isOperator (line 98) | public function isOperator() {
method isInList (line 102) | public function isInList() {
method isFunction (line 106) | public function isFunction() {
method isUnspecified (line 110) | public function isUnspecified() {
method isVariable (line 114) | public function isVariable() {
method isAggregateFunction (line 118) | public function isAggregateFunction() {
method isColumnReference (line 122) | public function isColumnReference() {
method isConstant (line 126) | public function isConstant() {
method isSign (line 130) | public function isSign() {
method isSubQuery (line 134) | public function isSubQuery() {
method revokeQuotation (line 138) | private function revokeQuotation($token, $qchars = '`') {
method toArray (line 150) | public function toArray() {
FILE: src/library/utils/ExpressionType.php
class ExpressionType (line 51) | class ExpressionType {
FILE: src/library/utils/PHPSQLParserConstants.php
class PHPSQLParserConstants (line 33) | class PHPSQLParserConstants {
method isAggregateFunction (line 168) | public static function isAggregateFunction($token) {
method isReserved (line 172) | public static function isReserved($token) {
method isFunction (line 176) | public static function isFunction($token) {
method isParameterizedFunction (line 180) | public static function isParameterizedFunction($token) {
FILE: src/library/utils/PHPSQLParserUtils.php
class PHPSQLParserUtils (line 39) | class PHPSQLParserUtils {
method preprint (line 47) | protected function preprint($arr, $return = false) {
method endsWith (line 66) | protected function endsWith($haystack, $needle) {
method revokeQuotation (line 77) | protected function revokeQuotation($sql) {
method removeParenthesisFromStart (line 90) | protected function removeParenthesisFromStart($token) {
method getLastOf (line 131) | public function getLastOf($array) {
method toArray (line 142) | public function toArray($tokenList) {
Condensed preview — 124 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (738K chars).
[
{
"path": "EsParser_realse.php",
"chars": 50875,
"preview": "<?php\n/*\n|---------------------------------------------------------------\n| Copyright (c) 2018\n|-----------------------"
},
{
"path": "README.md",
"chars": 4432,
"preview": "# EsParser\nphp的操作类库,通过写sql来转化dsl来查询elasticsearch\n### composer使用\n {\n \"require\": {\n \"qieangel2013/esp"
},
{
"path": "composer.json",
"chars": 407,
"preview": "{\n \"name\": \"qieangel2013/esparser\",\n \"description\": \"es php library\",\n \"type\": \"library\",\n \"keywords\": [\"sql"
},
{
"path": "index.php",
"chars": 1690,
"preview": "<?php\nrequire_once dirname(__FILE__) . '/src/library/EsParser.php';\n//$sql = 'select a.*,count(a.id) as id,sum(a.price) "
},
{
"path": "src/example.php",
"chars": 1686,
"preview": "<?php\nrequire_once dirname(__FILE__) . '/library/EsParser.php';\n//$sql = 'select a.*,count(a.id) as id,sum(a.price) as t"
},
{
"path": "src/library/EsCreator.php",
"chars": 4998,
"preview": "<?php\n/**\n * PHPSQLCreator.php\n *\n * A creator, which generates SQL from the output of PHPSQLParser.\n *\n * PHP version 5"
},
{
"path": "src/library/EsParser.php",
"chars": 159609,
"preview": "<?php\n/*\n|---------------------------------------------------------------\n| Copyright (c) 2018\n|-----------------------"
},
{
"path": "src/library/builders/AliasBuilder.php",
"chars": 2531,
"preview": "<?php\n/**\n * AliasBuilder.php\n *\n * Builds aliases.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2010-2014 Justin"
},
{
"path": "src/library/builders/CharacterSetBuilder.php",
"chars": 3665,
"preview": "<?php\n/**\n * CharacterSetBuilder.php\n *\n * Builds the CHARACTER SET part of a CREATE TABLE statement.\n *\n * PHP version "
},
{
"path": "src/library/builders/CheckBuilder.php",
"chars": 3364,
"preview": "<?php\n/**\n * CheckBuilder.php\n *\n * Builds the CHECK statement part of CREATE TABLE.\n *\n * PHP version 5\n *\n * LICENSE:\n"
},
{
"path": "src/library/builders/CollationBuilder.php",
"chars": 3581,
"preview": "<?php\n/**\n * CollationBuilder.php\n *\n * Builds the collation expression part of CREATE TABLE.\n *\n * PHP version 5\n *\n * "
},
{
"path": "src/library/builders/ColumnDefinitionBuilder.php",
"chars": 3384,
"preview": "<?php\n/**\n * ColumnDefinitionBuilder.php\n *\n * Builds the column definition statement part of CREATE TABLE.\n *\n * PHP ve"
},
{
"path": "src/library/builders/ColumnListBuilder.php",
"chars": 3102,
"preview": "<?php\n/**\n * ColumnListBuilder.php\n *\n * Builds column-list parts of CREATE TABLE.\n *\n * PHP version 5\n *\n * LICENSE:\n *"
},
{
"path": "src/library/builders/ColumnReferenceBuilder.php",
"chars": 2923,
"preview": "<?php\n/**\n * ColumnReferenceBuilder.php\n *\n * Builds Column references.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright "
},
{
"path": "src/library/builders/ColumnTypeBracketExpressionBuilder.php",
"chars": 2792,
"preview": "<?php\n/**\n * ColumnTypeExpressionBuilder.php\n *\n * Builds the bracket expressions within a column type.\n *\n * PHP versio"
},
{
"path": "src/library/builders/ColumnTypeBuilder.php",
"chars": 3690,
"preview": "<?php\n/**\n * ColumnTypeBuilder.php\n *\n * Builds the column type statement part of CREATE TABLE.\n *\n * PHP version 5\n *\n "
},
{
"path": "src/library/builders/ConstantBuilder.php",
"chars": 2672,
"preview": "<?php\n/**\n * ConstantBuilder.php\n *\n * Builds constant (String, Integer, etc.) parts.\n *\n * PHP version 5\n *\n * LICENSE:"
},
{
"path": "src/library/builders/ConstraintBuilder.php",
"chars": 2754,
"preview": "<?php\n/**\n * ConstraintBuilder.php\n *\n * Builds the constraint statement part of CREATE TABLE.\n *\n * PHP version 5\n *\n *"
},
{
"path": "src/library/builders/CreateBuilder.php",
"chars": 3066,
"preview": "<?php\n/**\n * CreateBuilder.php\n *\n * Builds the CREATE statement\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 201"
},
{
"path": "src/library/builders/CreateStatementBuilder.php",
"chars": 3112,
"preview": "<?php\n/**\n * CreateStatement.php\n *\n * Builds the CREATE statement\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2"
},
{
"path": "src/library/builders/CreateTableBuilder.php",
"chars": 3252,
"preview": "<?php\n/**\n * CreateTable.php\n *\n * Builds the CREATE TABLE statement\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c)"
},
{
"path": "src/library/builders/CreateTableDefinitionBuilder.php",
"chars": 2699,
"preview": "<?php\n/**\n * CreateTableDefinitionBuilder.php\n *\n * Builds the create definitions of CREATE TABLE.\n *\n * PHP version 5\n "
},
{
"path": "src/library/builders/CreateTableOptionsBuilder.php",
"chars": 4085,
"preview": "<?php\n/**\n * CreateTableOptionsBuilder.php\n *\n * Builds the table-options statement part of CREATE TABLE.\n *\n * PHP vers"
},
{
"path": "src/library/builders/CreateTableSelectOptionBuilder.php",
"chars": 2644,
"preview": "<?php\n/**\n * CreateTableSelectOptionBuilder.php\n *\n * Builds the select-options statement part of CREATE TABLE.\n *\n * PH"
},
{
"path": "src/library/builders/DataTypeBuilder.php",
"chars": 2463,
"preview": "<?php\n/**\n * DataTypeBuilder.php\n *\n * Builds the data-type statement part of CREATE TABLE.\n *\n * PHP version 5\n *\n * LI"
},
{
"path": "src/library/builders/DatabaseBuilder.php",
"chars": 2444,
"preview": "<?php\n/**\n * DatabaseBuilder.php\n *\n * Builds the database within the SHOW statement.\n *\n * PHP version 5\n *\n * LICENSE:"
},
{
"path": "src/library/builders/DeleteBuilder.php",
"chars": 2353,
"preview": "<?php\n/**\n * DeleteBuilder.php\n *\n * Builds the DELETE statement\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 201"
},
{
"path": "src/library/builders/DeleteStatementBuilder.php",
"chars": 3056,
"preview": "<?php\n/**\n * DeleteStatementBuilder.php\n *\n * Builds the DELETE statement\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyrigh"
},
{
"path": "src/library/builders/DirectionBuilder.php",
"chars": 2411,
"preview": "<?php\n/**\n * DirectionBuilder.php\n *\n * Builds direction (e.g. of the order-by clause).\n *\n * PHP version 5\n *\n * LICENS"
},
{
"path": "src/library/builders/EngineBuilder.php",
"chars": 2438,
"preview": "<?php\n/**\n * DatabaseBuilder.php\n *\n * Builds the database within the SHOW statement.\n *\n * PHP version 5\n *\n * LICENSE:"
},
{
"path": "src/library/builders/ForeignKeyBuilder.php",
"chars": 3846,
"preview": "<?php\n/**\n * ForeignKeyBuilder.php\n *\n * Builds the FOREIGN KEY statement part of CREATE TABLE.\n *\n * PHP version 5\n *\n "
},
{
"path": "src/library/builders/ForeignRefBuilder.php",
"chars": 3607,
"preview": "<?php\n/**\n * ForeignRefBuilder.php\n *\n * Builds the FOREIGN KEY REFERENCES statement part of CREATE TABLE.\n *\n * PHP ver"
},
{
"path": "src/library/builders/FromBuilder.php",
"chars": 3333,
"preview": "<?php\n/**\n * FromBuilder.php\n *\n * Builds the FROM statement\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2010-20"
},
{
"path": "src/library/builders/FunctionBuilder.php",
"chars": 5033,
"preview": "<?php\n/**\n * FunctionBuilder.php\n *\n * Builds function statements.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2"
},
{
"path": "src/library/builders/GroupByBuilder.php",
"chars": 3376,
"preview": "<?php\n/**\n * GroupByBuilder.php\n *\n * Builds the GROUP-BY clause.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 20"
},
{
"path": "src/library/builders/InListBuilder.php",
"chars": 2689,
"preview": "<?php\n/**\n * InListBuilder.php\n *\n * Builds lists of values for the IN statement.\n *\n * PHP version 5\n *\n * LICENSE:\n * "
},
{
"path": "src/library/builders/IndexColumnBuilder.php",
"chars": 2957,
"preview": "<?php\n/**\n * IndexColumnBuilder.php\n *\n * Builds the column entries of the column-list parts of CREATE TABLE.\n *\n * PHP "
},
{
"path": "src/library/builders/IndexParserBuilder.php",
"chars": 3524,
"preview": "<?php\n/**\n * IndexParserBuilder.php\n *\n * Builds index parser part of a PRIMARY KEY statement part of CREATE TABLE.\n *\n "
},
{
"path": "src/library/builders/IndexSizeBuilder.php",
"chars": 3510,
"preview": "<?php\n/**\n * IndexSizeBuilder.php\n *\n * Builds index size part of a PRIMARY KEY statement part of CREATE TABLE.\n *\n * PH"
},
{
"path": "src/library/builders/IndexTypeBuilder.php",
"chars": 3322,
"preview": "<?php\n/**\n * IndexTypeBuilder.php\n *\n * Builds index type part of a PRIMARY KEY statement part of CREATE TABLE.\n *\n * PH"
},
{
"path": "src/library/builders/InsertBuilder.php",
"chars": 3151,
"preview": "<?php\n/**\n * InsertBuilder.php\n *\n * Builds the [INSERT] statement part.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright"
},
{
"path": "src/library/builders/InsertStatementBuilder.php",
"chars": 2823,
"preview": "<?php\n/**\n * InsertStatement.php\n *\n * Builds the INSERT statement\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2"
},
{
"path": "src/library/builders/JoinBuilder.php",
"chars": 2710,
"preview": "<?php\n/**\n * JoinBuilder.php\n *\n * Builds the JOIN statement parts (within FROM).\n *\n * PHP version 5\n *\n * LICENSE:\n * "
},
{
"path": "src/library/builders/LikeBuilder.php",
"chars": 2739,
"preview": "<?php\n/**\n * LikeBuilder.php\n *\n * Builds the LIKE statement part of a CREATE TABLE statement.\n *\n * PHP version 5\n *\n *"
},
{
"path": "src/library/builders/LikeExpressionBuilder.php",
"chars": 3387,
"preview": "<?php\n/**\n * LikeExpressionBuilder.php\n *\n * Builds the LIKE keyword within parenthesis.\n *\n * PHP version 5\n *\n * LICEN"
},
{
"path": "src/library/builders/LimitBuilder.php",
"chars": 2528,
"preview": "<?php\n/**\n * LimitBuilder.php\n *\n * Builds the LIMIT statement.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2010"
},
{
"path": "src/library/builders/OperatorBuilder.php",
"chars": 2392,
"preview": "<?php\n/**\n * OperatorBuilder.php\n *\n * Builds operators.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2010-2014 J"
},
{
"path": "src/library/builders/OrderByAliasBuilder.php",
"chars": 2683,
"preview": "<?php\n/**\n * OrderByAliasBuilder.php\n *\n * Builds an alias within an ORDER-BY clause.\n *\n * PHP version 5\n *\n * LICENSE:"
},
{
"path": "src/library/builders/OrderByBuilder.php",
"chars": 3325,
"preview": "<?php\n/**\n * OrderByBuilder.php\n *\n * Builds the ORDERBY clause.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 201"
},
{
"path": "src/library/builders/PositionBuilder.php",
"chars": 2438,
"preview": "<?php\n/**\n * PositionBuilder.php\n *\n * Builds positions of the GROUP BY clause.\n *\n * PHP version 5\n *\n * LICENSE:\n * Co"
},
{
"path": "src/library/builders/PrimaryKeyBuilder.php",
"chars": 4357,
"preview": "<?php\n/**\n * PrimaryKeyBuilder.php\n *\n * Builds the PRIMARY KEY statement part of CREATE TABLE.\n *\n * PHP version 5\n *\n "
},
{
"path": "src/library/builders/ProcedureBuilder.php",
"chars": 2450,
"preview": "<?php\n/**\n * Procedureuilder.php\n *\n * Builds the procedures within the SHOW statement.\n *\n * PHP version 5\n *\n * LICENS"
},
{
"path": "src/library/builders/RecordBuilder.php",
"chars": 3568,
"preview": "<?php\n/**\n * RecordBuilder.php\n *\n * Builds the records within the INSERT statement.\n *\n * PHP version 5\n *\n * LICENSE:\n"
},
{
"path": "src/library/builders/RefClauseBuilder.php",
"chars": 3439,
"preview": "<?php\n/**\n * RefClauseBuilder.php\n *\n * Builds reference clauses within a JOIN.\n *\n * PHP version 5\n *\n * LICENSE:\n * Co"
},
{
"path": "src/library/builders/RefTypeBuilder.php",
"chars": 2591,
"preview": "<?php\n/**\n * RefTypeBuilder.php\n *\n * Builds reference type within a JOIN.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyrig"
},
{
"path": "src/library/builders/ReservedBuilder.php",
"chars": 2506,
"preview": "<?php\n/**\n * ReservedBuilder.php\n *\n * Builds reserved keywords.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 201"
},
{
"path": "src/library/builders/SelectBracketExpressionBuilder.php",
"chars": 2797,
"preview": "<?php\n/**\n * SelectBracketExpressionBuilder.php\n *\n * Builds the bracket expressions within a SELECT statement.\n *\n * PH"
},
{
"path": "src/library/builders/SelectBuilder.php",
"chars": 4573,
"preview": "<?php\n/**\n * SelectBuilder.php\n *\n * Builds the SELECT statement from the [SELECT] field.\n *\n * PHP version 5\n *\n * LICE"
},
{
"path": "src/library/builders/SelectExpressionBuilder.php",
"chars": 2960,
"preview": "<?php\n/**\n * SelectExpressionBuilder.php\n *\n * Builds simple expressions within a SELECT statement.\n *\n * PHP version 5\n"
},
{
"path": "src/library/builders/SelectStatementBuilder.php",
"chars": 3989,
"preview": "<?php\n/**\n * SelectStatement.php\n *\n * Builds the SELECT statement\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2"
},
{
"path": "src/library/builders/SetBuilder.php",
"chars": 2880,
"preview": "<?php\n/**\n * SetBuilder.php\n *\n * Builds the SET part of the INSERT statement.\n *\n * PHP version 5\n *\n * LICENSE:\n * Cop"
},
{
"path": "src/library/builders/SetExpressionBuilder.php",
"chars": 3843,
"preview": "<?php\n/**\n * SetExpressionBuilder.php\n *\n * Builds the SET part of the INSERT statement.\n *\n * PHP version 5\n *\n * LICEN"
},
{
"path": "src/library/builders/ShowBuilder.php",
"chars": 4367,
"preview": "<?php\n/**\n * ShowBuilder.php\n *\n * Builds the SHOW statement.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2010-2"
},
{
"path": "src/library/builders/ShowStatementBuilder.php",
"chars": 2776,
"preview": "<?php\n/**\n * ShowStatementBuilder.php\n *\n * Builds the SHOW statement.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright ("
},
{
"path": "src/library/builders/SubQueryBuilder.php",
"chars": 3753,
"preview": "<?php\n/**\n * SubQueryBuilder.php\n *\n * Builds the statements for sub-queries.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copy"
},
{
"path": "src/library/builders/SubTreeBuilder.php",
"chars": 4561,
"preview": "<?php\n/**\n * SubTreeBuilder.php\n *\n * Builds the statements for [sub_tree] fields.\n *\n * PHP version 5\n *\n * LICENSE:\n *"
},
{
"path": "src/library/builders/TableBracketExpressionBuilder.php",
"chars": 4270,
"preview": "<?php\n/**\n * TableBracketExpressionBuilder.php\n *\n * Builds the table expressions within the create definitions of CREAT"
},
{
"path": "src/library/builders/TableBuilder.php",
"chars": 3490,
"preview": "<?php\n/**\n * TableBuilder.php\n *\n * Builds the table name/join options.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright "
},
{
"path": "src/library/builders/TableExpressionBuilder.php",
"chars": 3805,
"preview": "<?php\n/**\n * TableExpressionBuilder.php\n *\n * Builds the table name/join options.\n *\n * PHP version 5\n *\n * LICENSE:\n * "
},
{
"path": "src/library/builders/UpdateBuilder.php",
"chars": 2267,
"preview": "<?php\n/**\n * UpdateBuilder.php\n *\n * Builds the UPDATE statement parts.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright "
},
{
"path": "src/library/builders/UpdateStatementBuilder.php",
"chars": 3014,
"preview": "<?php\n/**\n * UpdateStatement.php\n *\n * Builds the UPDATE statement\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2"
},
{
"path": "src/library/builders/UserVariableBuilder.php",
"chars": 2423,
"preview": "<?php\n/**\n * UserVariableBuilder.php\n *\n * Builds an user variable.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) "
},
{
"path": "src/library/builders/ValuesBuilder.php",
"chars": 2898,
"preview": "<?php\n/**\n * ValuesBuilder.php\n *\n * Builds the VALUES part of the INSERT statement.\n *\n * PHP version 5\n *\n * LICENSE:\n"
},
{
"path": "src/library/builders/WhereBracketExpressionBuilder.php",
"chars": 4764,
"preview": "<?php\n/**\n * WhereBracketExpressionBuilder.php\n *\n * Builds bracket expressions within the WHERE part.\n *\n * PHP version"
},
{
"path": "src/library/builders/WhereBuilder.php",
"chars": 4922,
"preview": "<?php\n/**\n * WhereBuilder.php\n *\n * Builds the WHERE part.\n *\n * PHP version 5\n *\n * LICENSE:\n * Copyright (c) 2010-2014"
},
{
"path": "src/library/builders/WhereExpressionBuilder.php",
"chars": 4927,
"preview": "<?php\n/**\n * WhereExpressionBuilder.php\n *\n * Builds expressions within the WHERE part.\n *\n * PHP version 5\n *\n * LICENS"
},
{
"path": "src/library/exceptions/InvalidParameterException.php",
"chars": 2082,
"preview": "<?php\n/**\n * InvalidParameterException.php\n *\n * This file implements the InvalidParameterException class which is used "
},
{
"path": "src/library/exceptions/UnableToCalculatePositionException.php",
"chars": 2377,
"preview": "<?php\n/**\n * UnableToCalculatePositionException.php\n *\n * This file implements the UnableToCalculatePositionException cl"
},
{
"path": "src/library/exceptions/UnableToCreateSQLException.php",
"chars": 2727,
"preview": "<?php\n/**\n * UnableToCreateSQLException.php\n *\n * This file implements the UnableToCreateSQLException class which is use"
},
{
"path": "src/library/exceptions/UnsupportedFeatureException.php",
"chars": 2196,
"preview": "<?php\n/**\n * UnsupportedFeatureException.php\n *\n * This file implements the UnsupportedFeatureException class which is u"
},
{
"path": "src/library/lexer/LexerSplitter.php",
"chars": 3845,
"preview": "<?php\n/**\n * LexerSplitter.php\n *\n * Defines the characters, which are used to split the given SQL string.\n * Part of PH"
},
{
"path": "src/library/lexer/PHPSQLLexer.php",
"chars": 10362,
"preview": "<?php\n/**\n * PHPSQLLexer.php\n *\n * This file contains the lexer, which splits and recombines parts of the \n * SQL statem"
},
{
"path": "src/library/positions/PositionCalculator.php",
"chars": 9754,
"preview": "<?php\n/**\n * position-calculator.php\n *\n * This file implements the calculator for the position elements of \n * the outp"
},
{
"path": "src/library/processors/AbstractProcessor.php",
"chars": 7203,
"preview": "<?php\n/**\n * AbstractProcessor.php\n *\n * This file implements an abstract processor, which implements some helper functi"
},
{
"path": "src/library/processors/ColumnDefinitionProcessor.php",
"chars": 17758,
"preview": "<?php\n/**\n * ColumnDefinitionProcessor.php\n *\n * This file implements the processor for column definition part of a CREA"
},
{
"path": "src/library/processors/ColumnListProcessor.php",
"chars": 2190,
"preview": "<?php\n/**\n * ColumnListProcessor.php\n *\n * This file implements the processor for column lists like in INSERT statements"
},
{
"path": "src/library/processors/CreateDefinitionProcessor.php",
"chars": 17036,
"preview": "<?php\n/**\n * CreateDefinitionProcessor.php\n *\n * This file implements the processor for the create definition within the"
},
{
"path": "src/library/processors/CreateProcessor.php",
"chars": 3333,
"preview": "<?php\n/**\n * CreateProcessor.php\n *\n * This file implements the processor for the CREATE TABLE statements.\n *\n * Copyrig"
},
{
"path": "src/library/processors/DefaultProcessor.php",
"chars": 2524,
"preview": "<?php\n/**\n * DefaultProcessor.php\n *\n * This file implements the processor the unparsed sql string given by the user.\n *"
},
{
"path": "src/library/processors/DeleteProcessor.php",
"chars": 2346,
"preview": "<?php\n/**\n * DeleteProcessor.php\n *\n * This file implements the processor for the DELETE statements.\n *\n * Copyright (c)"
},
{
"path": "src/library/processors/DescProcessor.php",
"chars": 1905,
"preview": "<?php\n/**\n * DescProcessor.php\n *\n * This file implements the processor for the DESC statements, which is a short form o"
},
{
"path": "src/library/processors/DescribeProcessor.php",
"chars": 1891,
"preview": "<?php\n/**\n * DescribeProcessor.php\n *\n * This file implements the processor for the DESCRIBE statements.\n *\n * Copyright"
},
{
"path": "src/library/processors/DropProcessor.php",
"chars": 3609,
"preview": "<?php\n/**\n * DropProcessor.php\n *\n * This file implements the processor for the DROP statements.\n *\n * Copyright (c) 201"
},
{
"path": "src/library/processors/DuplicateProcessor.php",
"chars": 1875,
"preview": "<?php\n/**\n * DuplicateProcessor.php\n *\n * This file implements the processor for the DUPLICATE statements.\n *\n * Copyrig"
},
{
"path": "src/library/processors/ExplainProcessor.php",
"chars": 4727,
"preview": "<?php\n/**\n * ExplainProcessor.php\n *\n * This file implements the processor for the EXPLAIN statements.\n *\n * Copyright ("
},
{
"path": "src/library/processors/ExpressionListProcessor.php",
"chars": 16074,
"preview": "<?php\n/**\n * ExpressionListProcessor.php\n *\n * This file implements the processor for expression lists.\n *\n * Copyright "
},
{
"path": "src/library/processors/FromProcessor.php",
"chars": 8926,
"preview": "<?php\n/**\n * FromProcessor.php\n *\n * This file implements the processor for the FROM statements.\n *\n * Copyright (c) 201"
},
{
"path": "src/library/processors/GroupByProcessor.php",
"chars": 2581,
"preview": "<?php\n/**\n * GroupByProcessor.php\n *\n * This file implements the processor for the GROUP-BY statements.\n *\n * Copyright "
},
{
"path": "src/library/processors/HavingProcessor.php",
"chars": 1773,
"preview": "<?php\n/**\n * HavingProcessor.php\n *\n * This file implements the processor for the HAVING statements.\n *\n * Copyright (c)"
},
{
"path": "src/library/processors/IndexColumnListProcessor.php",
"chars": 3480,
"preview": "<?php\n/**\n * IndexColumnListProcessor.php\n *\n * This file implements the processor for index column lists.\n *\n * Copyrig"
},
{
"path": "src/library/processors/InsertProcessor.php",
"chars": 2811,
"preview": "<?php\n/**\n * InsertProcessor.php\n *\n * This file implements the processor for the INSERT statements.\n *\n * Copyright (c)"
},
{
"path": "src/library/processors/IntoProcessor.php",
"chars": 2228,
"preview": "<?php\n/**\n * IntoProcessor.php\n *\n * This file implements the processor for the INTO statements.\n *\n * Copyright (c) 201"
},
{
"path": "src/library/processors/LimitProcessor.php",
"chars": 2730,
"preview": "<?php\n/**\n * LimitProcessor.php\n *\n * This file implements the processor for the LIMIT statements.\n *\n * Copyright (c) 2"
},
{
"path": "src/library/processors/OrderByProcessor.php",
"chars": 4539,
"preview": "<?php\n/**\n * OrderByProcessor.php\n *\n * This file implements the processor for the ORDER-BY statements.\n *\n * Copyright "
},
{
"path": "src/library/processors/RecordProcessor.php",
"chars": 2330,
"preview": "<?php\n/**\n * RecordProcessor.php\n *\n * This file implements the processor for records.\n *\n * Copyright (c) 2010-2012, Ju"
},
{
"path": "src/library/processors/ReferenceDefinitionProcessor.php",
"chars": 7192,
"preview": "<?php\n/**\n * ReferenceDefinitionProcessor.php\n *\n * This file implements the processor reference definition part of the "
},
{
"path": "src/library/processors/RenameProcessor.php",
"chars": 3680,
"preview": "<?php\n/**\n * RenameProcessor.php\n *\n * This file implements the processor for the RENAME statements.\n *\n * Copyright (c)"
},
{
"path": "src/library/processors/ReplaceProcessor.php",
"chars": 1893,
"preview": "<?php\n/**\n * ReplaceProcessor.php\n *\n * This file implements the processor for the REPLACE statements.\n *\n * Copyright ("
},
{
"path": "src/library/processors/SQLChunkProcessor.php",
"chars": 7843,
"preview": "<?php\n/**\n * SQLChunkProcessor.php\n *\n * This file implements the processor for the SQL chunks.\n *\n * Copyright (c) 2010"
},
{
"path": "src/library/processors/SQLProcessor.php",
"chars": 14785,
"preview": "<?php\n/**\n * SQLProcessor.php\n *\n * This file implements the processor for the base SQL statements.\n *\n * Copyright (c) "
},
{
"path": "src/library/processors/SelectExpressionProcessor.php",
"chars": 6389,
"preview": "<?php\n/**\n * SelectExpressionProcessor.php\n *\n * This file implements the processor for SELECT expressions.\n *\n * Copyri"
},
{
"path": "src/library/processors/SelectProcessor.php",
"chars": 3220,
"preview": "<?php\n/**\n * SelectProcessor.php\n *\n * This file implements the processor for the SELECT statements.\n *\n * Copyright (c)"
},
{
"path": "src/library/processors/SetProcessor.php",
"chars": 3848,
"preview": "<?php\n/**\n * SetProcessor.php\n *\n * This file implements the processor for the SET statements.\n *\n * Copyright (c) 2010-"
},
{
"path": "src/library/processors/ShowProcessor.php",
"chars": 6490,
"preview": "<?php\n/**\n * ShowProcessor.php\n *\n * This file implements the processor for the SHOW statements.\n *\n * Copyright (c) 201"
},
{
"path": "src/library/processors/TableProcessor.php",
"chars": 14289,
"preview": "<?php\n/**\n * TableProcessor.php\n *\n * This file implements the processor for the TABLE statements.\n *\n * Copyright (c) 2"
},
{
"path": "src/library/processors/UnionProcessor.php",
"chars": 6015,
"preview": "<?php\n/**\n * UnionProcessor.php\n *\n * This file implements the processor for the UNION statements.\n *\n * Copyright (c) 2"
},
{
"path": "src/library/processors/UpdateProcessor.php",
"chars": 1753,
"preview": "<?php\n/**\n * UpdateProcessor.php\n *\n * This file implements the processor for the UPDATE statements.\n *\n * Copyright (c)"
},
{
"path": "src/library/processors/UsingProcessor.php",
"chars": 1749,
"preview": "<?php\n/**\n * UsingProcessor.php\n *\n * This file implements the processor for the USING statements.\n *\n * Copyright (c) 2"
},
{
"path": "src/library/processors/ValuesProcessor.php",
"chars": 2817,
"preview": "<?php\n/**\n * ValuesProcessor.php\n *\n * This file implements the processor for the VALUES statements.\n *\n * Copyright (c)"
},
{
"path": "src/library/processors/WhereProcessor.php",
"chars": 1769,
"preview": "<?php\n/**\n * WhereProcessor.php\n *\n * This file implements the processor for the WHERE statements.\n *\n * Copyright (c) 2"
},
{
"path": "src/library/utils/ExpressionToken.php",
"chars": 4431,
"preview": "<?php\n\nrequire_once dirname(__FILE__) . '/ExpressionType.php';\n\nclass ExpressionToken {\n\n private $subTree;\n priva"
},
{
"path": "src/library/utils/ExpressionType.php",
"chars": 4097,
"preview": "<?php\n/**\n * ExpressionType.php\n *\n * Defines all values, which are possible for the [expr_type] field \n * within the pa"
},
{
"path": "src/library/utils/PHPSQLParserConstants.php",
"chars": 16734,
"preview": "<?php\n/**\n * constants.php\n *\n * Some constants for the PHPSQLParser.\n *\n * Copyright (c) 2010-2012, Justin Swanhart\n * "
},
{
"path": "src/library/utils/PHPSQLParserUtils.php",
"chars": 4718,
"preview": "<?php\n/**\n * PHPSQLParserUtils.php\n *\n * These are utility functions for the PHPSQLParser.\n *\n * Copyright (c) 2010-2012"
}
]
About this extraction
This page contains the full source code of the qieangel2013/EsParser GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 124 files (692.1 KB), approximately 159.1k tokens, and a symbol index with 556 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.