/**
  * Delete entity's corresponding database row.
  *
  * @param AbstractDbEntity $dbEntity
  */
 public function delete(AbstractDbEntity $dbEntity)
 {
     if (!$dbEntity->getPrimaryDbValue()) {
         throw new \InvalidArgumentException('Primary database value not set');
     }
     $this->db->exec('DELETE FROM `' . $dbEntity->getDbTableName() . '` WHERE ' . $this->getPrimaryKeyWhereSql($dbEntity), $this->getPrimaryKeyWhereParameters($dbEntity));
     $dbEntity->setDeleted();
 }
Example #2
0
 /**
  * Empty database.
  */
 public function emptyDb()
 {
     if ($rows = $this->db->fetchRows('SHOW TABLES', [], true)) {
         $this->db->exec('SET foreign_key_checks = 0');
         foreach ($rows as $row) {
             $this->db->exec('DROP TABLE `' . $row[0] . '`');
         }
         $this->db->exec('SET foreign_key_checks = 1');
     }
 }
Example #3
0
 /**
  * @param Logger $logger
  */
 public function clear(Logger $logger)
 {
     $this->db->exec(sprintf('DELETE FROM `%s` WHERE `channel` = ?', $this->table), [$logger->getName()]);
 }