for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Ubiquity\orm\bulk;
use Ubiquity\orm\OrmUtils;
/**
* Ubiquity\orm\bulk$BulkDeletes
* This class is part of Ubiquity
*
* @author jcheron <[email protected]>
* @version 1.0.0
*/
class BulkDeletes extends AbstractBulks {
public function addInstance($instance, $id = null) {
$id = $id ?? OrmUtils::getFirstKeyValue ( $instance );
$this->instances [$id] = $instance;
}
public function createSQL() {
$quote = $this->db->quote;
$tableName = OrmUtils::getTableName ( $this->class );
$this->parameters = \array_keys ( $this->instances );
$count = \count ( $this->parameters );
return "DELETE FROM {$quote}{$tableName}{$quote} WHERE {$quote}{$this->pkName}{$quote} IN (" . \implode ( ',', \array_fill ( 0, $count, '?' ) ) . ')';