Use PDO singleton
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace BitBadger\PDODocument;
|
||||
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Functions to delete documents
|
||||
*/
|
||||
@@ -14,12 +12,11 @@ class Delete
|
||||
*
|
||||
* @param string $tableName The table from which the document should be deleted
|
||||
* @param mixed $docId The ID of the document to be deleted
|
||||
* @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 byId(string $tableName, mixed $docId, ?PDO $pdo = null): void
|
||||
public static function byId(string $tableName, mixed $docId): void
|
||||
{
|
||||
Custom::nonQuery(Query\Delete::byId($tableName), Parameters::id($docId), $pdo);
|
||||
Custom::nonQuery(Query\Delete::byId($tableName), Parameters::id($docId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,15 +24,13 @@ class Delete
|
||||
*
|
||||
* @param string $tableName The table from which documents should be deleted
|
||||
* @param array|Field[] $fields The field comparison to match
|
||||
* @param PDO|null $pdo The database connection to use (optional; will obtain one if not provided)
|
||||
* @param string $conjunction How to handle multiple conditions (optional; defaults to `AND`)
|
||||
* @throws DocumentException If any is encountered
|
||||
*/
|
||||
public static function byFields(string $tableName, array $fields, ?PDO $pdo = null,
|
||||
string $conjunction = 'AND'): void
|
||||
public static function byFields(string $tableName, array $fields, string $conjunction = 'AND'): void
|
||||
{
|
||||
$namedFields = Parameters::nameFields($fields);
|
||||
Custom::nonQuery(Query\Delete::byFields($tableName, $namedFields, $conjunction),
|
||||
Parameters::addFields($namedFields, []), $pdo);
|
||||
Parameters::addFields($namedFields, []));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user