static
This commit is contained in:
		
							parent
							
								
									7e7e0dfe6c
								
							
						
					
					
						commit
						be4eef7cac
					
				|  | @ -15,7 +15,7 @@ class JobModel extends BaseModel { | ||||||
|         echo "init "; |         echo "init "; | ||||||
|         if (static::$query === null) { |         if (static::$query === null) { | ||||||
|             echo "query "; |             echo "query "; | ||||||
|             static::$query = new JobQuery($this); |             static::$query = new JobQuery(self::class); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     public static function GetLast10() { |     public static function GetLast10() { | ||||||
|  |  | ||||||
|  | @ -9,11 +9,11 @@ abstract class Model { | ||||||
|     protected static ?string $table = null; |     protected static ?string $table = null; | ||||||
|     protected static ?IQuery $query = null; |     protected static ?IQuery $query = null; | ||||||
|      |      | ||||||
|     public function getTableName() { |     public static function getTableName() { | ||||||
|         return static::$table; |         return static::$table; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     public function getPrimaryKey() { |     public static function getPrimaryKey() { | ||||||
|         return static::$primaryKey; |         return static::$primaryKey; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |  | ||||||
|  | @ -4,9 +4,10 @@ namespace Fufle\ORM; | ||||||
| class Query { | class Query { | ||||||
|     private string $table; |     private string $table; | ||||||
|     private string $primaryKey; |     private string $primaryKey; | ||||||
|     public function __construct(Model $model) { |     public function __construct(string $model) { | ||||||
|         $this->table = $model->getTableName(); |         ,//$model = new $class();
 | ||||||
|         $this->primaryKey = $model->getPrimaryKey(); |         $this->table = $model::getTableName(); | ||||||
|  |         $this->primaryKey = $model::getPrimaryKey(); | ||||||
|     } |     } | ||||||
|     public function Get(): string { |     public function Get(): string { | ||||||
|         return 'SELECT * FROM '.$this->table.' WHERE '.$this->primaryKey.' = ?'; |         return 'SELECT * FROM '.$this->table.' WHERE '.$this->primaryKey.' = ?'; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue