Delete.php 880 Bytes
Newer Older
ayelet_Cr's avatar
ayelet_Cr committed
1
2
<?php

3
namespace Drupal\Core\Database\Driver\sqlite;
ayelet_Cr's avatar
ayelet_Cr committed
4

5
use Drupal\Core\Database\Query\Delete as QueryDelete;
ayelet_Cr's avatar
ayelet_Cr committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

/**
 * SQLite specific implementation of DeleteQuery.
 *
 * When the WHERE is omitted from a DELETE statement and the table being deleted
 * has no triggers, SQLite uses an optimization to erase the entire table content
 * without having to visit each row of the table individually.
 *
 * Prior to SQLite 3.6.5, SQLite does not return the actual number of rows deleted
 * by that optimized "truncate" optimization.
 */
class Delete extends QueryDelete {
  public function execute() {
    if (!count($this->condition)) {
      $total_rows = $this->connection->query('SELECT COUNT(*) FROM {' . $this->connection->escapeTable($this->table) . '}')->fetchField();
      parent::execute();
      return $total_rows;
    }
    else {
      return parent::execute();
    }
  }
28
}