Use PDO singleton
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace BitBadger\PDODocument;
|
||||
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Functions to remove fields from documents
|
||||
*/
|
||||
@@ -15,14 +13,13 @@ class RemoveFields
|
||||
* @param string $tableName The table in which the document should have fields removed
|
||||
* @param mixed $docId The ID of the document from which fields should be removed
|
||||
* @param array|string[] $fieldNames The names of the fields to be removed
|
||||
* @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, array $fieldNames, ?PDO $pdo = null): void
|
||||
public static function byId(string $tableName, mixed $docId, array $fieldNames): void
|
||||
{
|
||||
$nameParams = Parameters::fieldNames(':name', $fieldNames);
|
||||
Custom::nonQuery(Query\RemoveFields::byId($tableName, $nameParams),
|
||||
array_merge(Parameters::id($docId), $nameParams), $pdo);
|
||||
array_merge(Parameters::id($docId), $nameParams));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,16 +28,15 @@ class RemoveFields
|
||||
* @param string $tableName The table in which documents should have fields removed
|
||||
* @param array|Field[] $fields The field comparison to match
|
||||
* @param array|string[] $fieldNames The names of the fields to be removed
|
||||
* @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, array $fieldNames, ?PDO $pdo = null,
|
||||
public static function byFields(string $tableName, array $fields, array $fieldNames,
|
||||
string $conjunction = 'AND'): void
|
||||
{
|
||||
$nameParams = Parameters::fieldNames(':name', $fieldNames);
|
||||
$namedFields = Parameters::nameFields($fields);
|
||||
Custom::nonQuery(Query\RemoveFields::byFields($tableName, $namedFields, $nameParams, $conjunction),
|
||||
Parameters::addFields($namedFields, $nameParams), $pdo);
|
||||
Parameters::addFields($namedFields, $nameParams));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user