Use PDO singleton
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace BitBadger\PDODocument;
|
||||
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Functions to create tables and indexes
|
||||
*/
|
||||
@@ -13,13 +11,12 @@ class Definition
|
||||
* Ensure a document table exists
|
||||
*
|
||||
* @param string $name The name of the table to be created if it does not exist
|
||||
* @param PDO|null $pdo The database connection to use (optional; will obtain one if not provided)
|
||||
* @throws DocumentException If any is encountered
|
||||
*/
|
||||
public static function ensureTable(string $name, ?PDO $pdo = null): void
|
||||
public static function ensureTable(string $name): void
|
||||
{
|
||||
Custom::nonQuery(Query\Definition::ensureTable($name), [], $pdo);
|
||||
Custom::nonQuery(Query\Definition::ensureKey($name), [], $pdo);
|
||||
Custom::nonQuery(Query\Definition::ensureTable($name), []);
|
||||
Custom::nonQuery(Query\Definition::ensureKey($name), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,11 +25,10 @@ class Definition
|
||||
* @param string $tableName The name of the table which should be indexed
|
||||
* @param string $indexName The name of the index
|
||||
* @param array $fields Fields which should be a part of this index
|
||||
* @param PDO|null $pdo The database connection to use (optional; will obtain one if not provided)
|
||||
* @throws DocumentException If any is encountered
|
||||
*/
|
||||
public static function ensureFieldIndex(string $tableName, string $indexName, array $fields, ?PDO $pdo = null): void
|
||||
public static function ensureFieldIndex(string $tableName, string $indexName, array $fields): void
|
||||
{
|
||||
Custom::nonQuery(Query\Definition::ensureIndexOn($tableName, $indexName, $fields), [], $pdo);
|
||||
Custom::nonQuery(Query\Definition::ensureIndexOn($tableName, $indexName, $fields), []);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user