Рефакторинг

This commit is contained in:
origami11 2017-02-17 15:08:12 +03:00
parent 1b5852cc43
commit 981a1d0f0f
11 changed files with 626 additions and 270 deletions

View file

@ -0,0 +1,26 @@
<?php
class Database_IdGenerator {
private $db;
function __construct(Database $db) {
$this->db = $db;
}
function isBeforeInsert() {
return $this->db->isPostgres();
}
function isAfterInsert() {
return !$this->db->isPostgres();
}
function getId($seq) {
if ($this->db->isPostgres()) {
$result = $this->db->fetchOneArray("SELECT nextval('$seq') AS nextval");
} else {
$result = $this->db->fetchOneArray("SELECT last_insert_rowid() AS nextval");
}
return intval($result['nextval']);
}
}