User.php 576 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: root
  5. * Date: 31.07.18
  6. * Time: 11:27
  7. */
  8. require_once "Model.php";
  9. class User extends Model
  10. {
  11. public function __construct()
  12. {
  13. static::$table = "user";
  14. static::$fields = ['name'];
  15. static::$pk = "id";
  16. parent::__construct();
  17. }
  18. public function createRow(string $name)
  19. {
  20. $query =
  21. "INSERT INTO " . self::$table . "(`" . implode("`, `", self::$fields) . "`)" .
  22. " VALUES (" . "'" . $name . "'" . ");";
  23. $this->connection->exec($query);
  24. }
  25. }