12345678910111213141516171819202122232425262728 |
- <?php
- /**
- * Created by PhpStorm.
- * User: root
- * Date: 31.07.18
- * Time: 10:58
- */
- class Book extends Model
- {
- public function __construct()
- {
- static::$table = "book";
- static::$fields = ['name', 'year', 'user_id'];
- static::$pk = "id";
- parent::__construct();
- }
- public function createRow(string $name, string $year, string $user_id)
- {
- $query =
- "INSERT INTO" . self::$table . " (`" . implode("`, `", self::$fields) . "`)" .
- " VALUES (" . $name . ", " . $year . ", " . $user_id . ");";
- $this->connection->exec($query);
- }
- }
|