fix: Определения типов

This commit is contained in:
origami11@yandex.ru 2025-10-01 12:37:39 +03:00
parent 9f6fd74b17
commit dd74a97894
28 changed files with 334 additions and 249 deletions

View file

@ -42,8 +42,8 @@ class JsonInstall {
return $missingTables;
}
//Создать таблицы
function initDataBase($initActions/*: array*/, $dbinit_path) {
// Создать таблицы
function initDataBase(array $initActions, $dbinit_path) {
$pg = $this->db_manager->db->isPostgres();
if (!$pg) {
$refs = [];

View file

@ -9,14 +9,15 @@ use Exception;
class Manager
{
public $db/*: Database*/;
/** @var Database */
public $db;
public function __construct(Database $db)
{
$this->db = $db;
}
public function executeAction($action/*: array*/, $db_file = "")
public function executeAction(array $action, $db_file = "")
{
switch($action["type"]) {
case "dropTable":
@ -117,7 +118,7 @@ class Manager
return;
}
$data/*: array*/ = $this->dumpTable($table);
$data = $this->dumpTable($table);
$this->db->query("ALTER TABLE ".$table." RENAME TO ".$tmp_table.";");
$table_info[$new_name] = $table_info[$old_name];
@ -169,7 +170,7 @@ class Manager
$this->db->query($q);
}
public function getConstraintDef($c/*: array*/)
public function getConstraintDef(array $c)
{
if ($c['type'] == 'unique') {
return "UNIQUE(" . implode(", ", $c['fields']) . ")";
@ -209,7 +210,7 @@ class Manager
foreach ($table_fields as $name => $value) {
$type = strtolower($value['type']);
if ($type == "boolean") {
foreach ($data as &$row) {
foreach ($data as &$row) {
if (isset($row[$name])) {
$row[$name] = boolval($row[$name]);
}

View file

@ -16,7 +16,11 @@ class Statement
protected $conn;
protected $query;
function __construct($query, $conn/*: Database*/) {
/**
* @param string $query
* @param Database $conn
*/
function __construct($query, $conn) {
$this->query = $query;
$this->conn = $conn;
}
@ -45,7 +49,7 @@ class Statement
if ($this->limit) {
$this->query .= " LIMIT {$this->limit} OFFSET {$this->offset}";
}
$stmt/*: PDOStatement*/ = $this->conn->prepare($this->query);
$stmt = $this->conn->prepare($this->query);
foreach ($this->binds as $bind) {
list($n, $value, $type) = $bind;
$stmt->bindValue($n, $value, (int) $type);

View file

@ -10,7 +10,10 @@ class StatementIterator implements \Iterator
private $pos = 0;
private $row_count;
public function __construct($rs/*: PDOStatement*/) {
/**
* @param PDOStatement $rs
*/
public function __construct($rs) {
$this->result = $rs;
$this->row_count = $rs->getRecordCount();
}