You've already forked qlg.tsgz.moe
							
							Init Repo
This commit is contained in:
		
							
								
								
									
										25
									
								
								hyhproject/common/model/Base.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								hyhproject/common/model/Base.php
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| <?php | ||||
| namespace wstmart\common\model; | ||||
| use think\Model; | ||||
| use think\Db; | ||||
| /** | ||||
|  * ============================================================================ | ||||
|  * 基础模型器 | ||||
|  */ | ||||
|  | ||||
| class Base extends Model { | ||||
| 	/** | ||||
| 	 * 获取空模型 | ||||
| 	 */ | ||||
| 	public function getEModel($tables){ | ||||
| 		$rs =  Db::query('show columns FROM `'.config('database.prefix').$tables."`"); | ||||
| 		$obj = []; | ||||
| 		if($rs){ | ||||
| 			foreach($rs as $key => $v) { | ||||
| 				$obj[$v['Field']] = $v['Default']; | ||||
| 				if($v['Key'] == 'PRI')$obj[$v['Field']] = 0; | ||||
| 			} | ||||
| 		} | ||||
| 		return $obj; | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user