test
This commit is contained in:
		
							parent
							
								
									ac6b4b5d71
								
							
						
					
					
						commit
						6022747aed
					
				|  | @ -0,0 +1,38 @@ | ||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | interface ISqlBase { | ||||||
|  |     public function Get(): string; | ||||||
|  |     //public function Insert(): string;
 | ||||||
|  |     //public function Update(): string;
 | ||||||
|  |     //public function Delete(): string;
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | class BaseModel { | ||||||
|  |     protected $sql; | ||||||
|  |      | ||||||
|  |     public function __construct(ISqlBase $sql) { | ||||||
|  |         $this->sql = $sql; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static function Get(int $id) { | ||||||
|  |         return __CLASS__; | ||||||
|  |          $stmt = $pdo->prepare('SELECT id, name FROM users WHERE id=?'); | ||||||
|  |          $stmt->execute([$id]); | ||||||
|  |          return $stmt->fetchObject(__CLASS__); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | class JobSql implements ISqlBase { | ||||||
|  |     public function Get(): string { | ||||||
|  |         return ""; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | class Job extends BaseModel { | ||||||
|  |     public function __construct() { | ||||||
|  |         parent::__construct( new JobSql() ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | echo Job::Get(10); | ||||||
		Loading…
	
		Reference in New Issue