Closed orzass closed 6 years ago
medoo has no column functions too bad...
//// [ '#COUNT(id)(count)', // count("id") as "count" '#COUNT(id)' // count("id") ]
only change column_push method. add #preg_match test
it work on my project is better.
////////////////////
protected function column_push($columns) .....
foreach ($columns as $key => $value) { preg_match('/^#([a-zA-Z0-9_\-]*)\(([a-zA-Z0-9_\-\.]*)\)\s*(\(([a-zA-Z0-9_\-]*)\))?/i', $value, $match); if(isset($match[1], $match[2])){ $column_fn = $match[1] . '('. $this->column_quote( $match[2] ) . ')'; if( count($match) === 5 ){ array_push($stack, $column_fn . ' AS ' . $this->column_quote( $match[4] )); }else{ array_push($stack, $column_fn); } }else{ preg_match('/([a-zA-Z0-9_\-\.]*)\s*\(([a-zA-Z0-9_\-]*)\)/i', $value, $match); if (isset($match[1], $match[2])) { array_push($stack, $this->column_quote( $match[1] ) . ' AS ' . $this->column_quote( $match[2] )); } else { array_push($stack, $this->column_quote( $value )); } } } return implode($stack, ',');
ps. not support , e.g #count()
Check out the new feature raw object https://medoo.in/api/raw.
medoo has no column functions too bad...
//// [ '#COUNT(id)(count)', // count("id") as "count" '#COUNT(id)' // count("id") ]
only change column_push method. add #preg_match test
it work on my project is better.
////////////////////
protected function column_push($columns) .....