mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
Use PDO::fetchColumn()
where applicable
This commit is contained in:
parent
d2ce60d4c0
commit
47b214ee1b
@ -64,13 +64,13 @@ abstract class DbMigrationHook implements Countable
|
|||||||
*/
|
*/
|
||||||
public static function tableExists(Connection $conn, string $table): bool
|
public static function tableExists(Connection $conn, string $table): bool
|
||||||
{
|
{
|
||||||
/** @var stdClass $query */
|
/** @var false|int $exists */
|
||||||
$query = $conn->prepexec(
|
$exists = $conn->prepexec(
|
||||||
'SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = ?) AS result',
|
'SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = ?) AS result',
|
||||||
$table
|
$table
|
||||||
)->fetch(PDO::FETCH_OBJ);
|
)->fetchColumn();
|
||||||
|
|
||||||
return $query->result;
|
return (bool) $exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,18 +122,13 @@ abstract class DbMigrationHook implements Countable
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pdoStmt = $conn->prepexec(
|
/** @var false|string $collation */
|
||||||
|
$collation = $conn->prepexec(
|
||||||
'SELECT collation_name FROM information_schema.columns WHERE table_name = ? AND column_name = ?',
|
'SELECT collation_name FROM information_schema.columns WHERE table_name = ? AND column_name = ?',
|
||||||
[$table, $column]
|
[$table, $column]
|
||||||
);
|
)->fetchColumn();
|
||||||
|
|
||||||
/** @var false|stdClass $result */
|
return ! $collation ? null : $collation;
|
||||||
$result = $pdoStmt->fetch(PDO::FETCH_OBJ);
|
|
||||||
if ($result === false) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result->collation_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user