api接口
This commit is contained in:
@@ -22,11 +22,14 @@ class Fastphp
|
||||
|
||||
//运行程序
|
||||
public function run(){
|
||||
global $is_script;
|
||||
spl_autoload_register(array($this,'loadClass'));
|
||||
$this->setReporting();
|
||||
$this->unregisterGlobals();
|
||||
$this->setDbConfig();
|
||||
$this->route();
|
||||
if(!$is_script){
|
||||
$this->route();
|
||||
}
|
||||
}
|
||||
|
||||
//路由处理
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user