Author.php 553 B

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