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