PdoSqlite.php 836 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * MINZ - Copyright 2011 Marien Fressinaud
  5. * Sous licence AGPL3 <http://www.gnu.org/licenses/>
  6. */
  7. class Minz_PdoSqlite extends Minz_Pdo {
  8. /**
  9. * @param array<int,int|string|bool>|null $options
  10. * @throws PDOException
  11. */
  12. public function __construct(string $dsn, ?string $username = null, ?string $passwd = null, ?array $options = null) {
  13. parent::__construct($dsn, $username, $passwd, $options);
  14. $this->exec('PRAGMA foreign_keys = ON;');
  15. }
  16. #[\Override]
  17. public function dbType(): string {
  18. return 'sqlite';
  19. }
  20. /**
  21. * @throws PDOException if the attribute `PDO::ATTR_ERRMODE` is set to `PDO::ERRMODE_EXCEPTION`
  22. */
  23. #[\Override]
  24. public function lastInsertId(?string $name = null): string|false {
  25. return parent::lastInsertId(); //We discard the name, only used by PostgreSQL
  26. }
  27. }