api接口

This commit is contained in:
wanyongkang
2020-10-05 13:43:53 +08:00
parent a331e3f1d5
commit ce067b91dc
9 changed files with 198 additions and 103 deletions

View File

@@ -29,19 +29,19 @@ class Sql
$this->param = [];
$this->filter = '';
if($where){
$this->filter .= 'WHERE ';
$this->filter .= ' WHERE ';
if(is_string($where)){
$this->filter .= $where;
$this->filter .= ' '.$where;
} else {
$flag = true;
foreach ($where as $key => $value){
if($flag){
$flag = false;
if(is_array($value)){
$this->filter .= '`'.$key.'` '.$value[0].' :'.$key;
$this->filter .= ' `'.$key.'` '.$value[0].' :'.$key;
$this->param[$key] = $value[1];
} else {
$this->filter .= '`'.$key.'` = :'.$key;
$this->filter .= ' `'.$key.'` = :'.$key;
$this->param[$key] = $value;
}
} else {
@@ -64,14 +64,14 @@ class Sql
* @param array $order 排序条件
* @return $this
*/
public function order($order = []){
public function order($order = 'id',$type = 'desc'){
if($order){
$this->filter .= 'ORDER BY ';
$this->filter .= implode(' ,',$order);
$this->filter .= ' ORDER BY '.$order.' '.$type.' ';
}
return $this;
}
/**
* group by
* @param array $order
@@ -79,12 +79,22 @@ class Sql
*/
public function group($order = []){
if($order){
$this->filter .= 'GROUP BY ';
$this->filter .= implode(' ,',$order);
$this->filter .= ' GROUP BY ';
$this->filter .= ' '.implode(' ,',$order).' ';
}
return $this;
}
/**
* 查询limit
* @param string
* @return $this
*/
public function limit($limit = '100'){
$this->filter .= ' LIMIT '.$limit.' ';
return $this;
}
/**
* 查询字段
* @param string $field