database api start

This commit is contained in:
2023-01-09 20:27:01 +01:00
parent a8af7fa700
commit f14a7a4762
9 changed files with 174 additions and 31 deletions

View File

@@ -4,6 +4,9 @@ namespace Core\Driver\SQL;
use Core\API\Parameter\Parameter;
use Core\Driver\SQL\Condition\Compare;
use Core\Driver\SQL\Condition\CondLike;
use Core\Driver\SQL\Expression\Count;
use DateTime;
use Core\Driver\SQL\Column\Column;
use Core\Driver\SQL\Column\IntColumn;
@@ -453,6 +456,18 @@ class MySQL extends SQL {
return $query;
}
public function tableExists(string $tableName): bool {
$tableSchema = $this->connectionData->getProperty("database");
$res = $this->select(new Count())
->from("information_schema.TABLES")
->where(new Compare("TABLE_NAME", $tableName, "=", true))
->where(new Compare("TABLE_SCHEMA", $tableSchema, "=", true))
->where(new CondLike(new Column("TABLE_TYPE"), "BASE TABLE"))
->execute();
return $res && $res[0]["count"] > 0;
}
}
class RowIteratorMySQL extends RowIterator {