Method Documentation: deleteMany
Purpose
The deleteMany
method is designed to efficiently delete multiple records from the 'Users' table that match specific criteria. It operates within a transaction to ensure data integrity and consistency during the deletion process.
Parameters
array $criteria
- An associative array specifying the conditions for selecting the records to be deleted. Keys are field names, and values are the conditions those fields must meet for a record to be included in the deletion.
Return Value
The number of rows affected by the delete operation, indicating how many records were removed from the database.
Error Handling
If the database operation encounters a failure, an exception is thrown, ensuring that errors are appropriately managed and reported.
Example Usage
use Lib\Prisma\Classes\Prisma;
$prisma = Prisma::getInstance();
$deletedRows = $prisma->User->deleteMany([
'where' => ['roleId' => 1],
]);
echo "<pre>";
echo "deletedMany: " . print_r($deletedMany, true);
echo "</pre>";