diff --git a/4dev/tests/DB/CoreLibsDBIOTest.php b/4dev/tests/DB/CoreLibsDBIOTest.php index d6fa9408..ec8a28e1 100644 --- a/4dev/tests/DB/CoreLibsDBIOTest.php +++ b/4dev/tests/DB/CoreLibsDBIOTest.php @@ -160,15 +160,12 @@ final class CoreLibsDBIOTest extends TestCase // create the tables $db->dbExec( // primary key name is table + '_id' + // table_with_primary_key_id SERIAL PRIMARY KEY, <<dbExec( <<__dbQuery($q)) { - if (is_array($res = $this->__dbFetchArray($q))) { + if ($cursor = $this->__dbQueryParams($q, [$table, $pk_name])) { + if (is_array($res = $this->__dbFetchArray($cursor))) { list($id) = $res; } else { return false; @@ -451,26 +447,67 @@ class PgSQL implements Interface\SqlFunctions $table_prefix = $schema . '.'; } } + $params = [$table_prefix . $table]; + $replace = ['', '']; // read from table the PK name // faster primary key get - $q = "SELECT pg_attribute.attname AS column_name, " - . "format_type(pg_attribute.atttypid, pg_attribute.atttypmod) AS type " - . "FROM pg_index, pg_class, pg_attribute "; + /* $q = <<__dbQuery($q); + $q .= <<__dbQueryParams(str_replace( + ['{PG_NAMESPACE}', '{NSPNAME}'], + $replace, + $q + ), $params); if ($cursor !== false) { $__db_fetch_array = $this->__dbFetchArray($cursor); if (!is_array($__db_fetch_array)) { @@ -895,11 +932,13 @@ class PgSQL implements Interface\SqlFunctions public function __dbSetSchema(string $db_schema): int { // check if schema actually exists - $query = "SELECT EXISTS(" - . "SELECT 1 FROM information_schema.schemata " - . "WHERE schema_name = " . $this->__dbEscapeLiteral($db_schema) - . ")"; - $cursor = $this->__dbQuery($query); + $query = <<__dbQueryParams($query, [$db_schema]); // abort if execution fails if ($cursor === false) { return 1;