Truncates a table.

@throws    Fuel\Database_Exception
@param     string    $table    the table name
@return    int       the number of affected rows
966684
public static function truncate_table($table, $db = null)
	{
		return \DB::query('TRUNCATE TABLE '.\DB::quote_identifier(\DB::table_prefix($table, $db ? $db : static::$connection), $db ? $db : static::$connection), \DB::DELETE)
			->execute($db ? $db : static::$connection);
	}
505000
public function truncate()
    {
        $this->db->setQuery('TRUNCATE TABLE ' . $this->db->quoteName($this->getName()))->execute();

        return $this;
    }
658062
public function paginate(Table $table)
    {
        $ands = [];
        foreach ($this->sqlAnds as $filter => $ors)
            $ands[] = '(' . join(') OR (', $ors) . ')';

        $where = '';
        if (strlen($this->initialWhere) > 0) {
            $where = ' WHERE (' . $this->initialWhere . ')';
            if (count($ands))
                $where .= ' AND (' . join(') AND (', $ands) . ')';
        } else if (count($ands)) {
            $where = ' WHERE (' . join(') AND (', $ands) . ')';
        }

        $preparedParams = [];
        foreach ($this->sqlParams as $name => $value) {
            if ($value instanceof \DateTime)
                $preparedParams[$name] = $value->format('Y-m-d H:i:s');
            else
                $preparedParams[$name] = $value;
        }

        $db = $this->getPdo();
        $mapper = $table->getMapper();
        if (!$mapper)
            throw new \Exception("Data 'mapper' is required when using PDOAdapter");

        $sql = "SELECT COUNT(*) AS count"
             . "  FROM " . $this->initialFrom . " "
             . $where . " ";
        $sth = $db->prepare($sql);
        $sth->execute($preparedParams);
        $result = $sth->fetchAll(\PDO::FETCH_ASSOC);
        $count = $result[0]['count'];

        $table->calculatePageParams($count);

        if ($this->sqlOrderBy)
            $where .= ' ORDER BY ' . $this->sqlOrderBy . ' ';
        if ($table->getPageSize() > 0) {
            $where .= ' LIMIT ' . $table->getPageSize() . ' ';
            $where .= ' OFFSET ' . ($table->getPageSize() * ($table->getPageNumber() - 1)) . ' ';
        }

        $sql = "SELECT " . $this->initialSelect . " "
             . "  FROM " . $this->initialFrom . " "
             . $where . " ";
        $sth = $db->prepare($sql);
        $sth->execute($preparedParams);
        $result = $sth->fetchAll(\PDO::FETCH_ASSOC);

        $data = [];
        foreach ($result as $row) {
            foreach ($table->getColumns() as $columnId => $columnParams) {
                $value = $row[$columnId];
                if ($value === null)
                    continue;

                if ($columnParams['type'] == Table::TYPE_DATETIME) {
                    if (is_string($value)) {
                        if ($this->getDbTimezone())
                            $dt = new \DateTime($value, new \DateTimeZone($this->getDbTimezone()));
                        else
                            $dt = new \DateTime($value);
                    } else if (is_int($value)) {
                        $dt = new \DateTime('@' . $value);
                    } else {
                        $dt = $value;
                    }
                    if (date_default_timezone_get())
                        $dt->setTimezone(new \DateTimeZone(date_default_timezone_get()));
                    $row[$columnId] = $dt;
                }
            }

            $data[] = $mapper ? $mapper($row) : $row;
        }

        return $data;
    }
921907
public function delete($table){
		$statement = Statement::createDelete($this->connection, $table);
		foreach($this->observers as $observer){
			$statement->attachObserver($observer, $this->observers->getInfo());
		}
		return $statement;
	}
1042754
public function dontRequireTable($table)
    {
        if (!isset($this->tableList[strtolower($table)])) {
            return;
        }
        $prefix = "_obsolete_{$table}";
        $suffix = '';
        $renameTo = $prefix . $suffix;
        while (isset($this->tableList[strtolower($renameTo)])) {
            $suffix = $suffix
                    ? ((int)$suffix + 1)
                    : 2;
            $renameTo = $prefix . $suffix;
        }
        $renameFrom = $this->tableList[strtolower($table)];
        $this->renameTable($renameFrom, $renameTo);
        $this->alterationMessage("Table $table: renamed to $renameTo", "obsolete");
    }
346069
public function truncate()
    {
        foreach ($this->tables as $table) {
            $this->db->query("DELETE FROM $table");
        }

        $this->tables = array();
    }
767368
public function deleteFrom(string $table, array $where): int
    {
        $delete = new Delete($this->options);
        $sqlParams = $delete->buildQuery($table, $where);
        return $this->query($sqlParams->getSql(), $sqlParams->getParams())->getAffected();
    }
268040
public function filter($table)
    {
        $table->setMetadata(DataTable::TOTAL_ROWS_BEFORE_LIMIT_METADATA_NAME, $table->getRowsCount());

        if ($this->keepSummaryRow) {
            $summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
        }

        // we delete from 0 to offset
        if ($this->offset > 0) {
            $table->deleteRowsOffset(0, $this->offset);
        }
        // at this point the array has offset less elements. We delete from limit to the end
        if ($this->limit >= 0) {
            $table->deleteRowsOffset($this->limit);
        }

        if ($this->keepSummaryRow && !empty($summaryRow)) {
            $table->addSummaryRow($summaryRow);
        }
    }
342379
public function dropAutoincrement($table)
    {
        assert($this->_platform instanceof OraclePlatform);

        $sql = $this->_platform->getDropAutoincrementSql($table);
        foreach ($sql as $query) {
            $this->_conn->executeUpdate($query);
        }

        return true;
    }
1092956
public function truncate(string $table)
    {
        $compiler = $this->connection->schemaCompiler();

        $result = $compiler->truncate($table);

        $this->connection->command($result['sql'], $result['params']);
    }
294966
protected function _delete($table)
	{
		if ($this->qb_limit)
		{
			return 'WITH ci_delete AS (SELECT TOP '.$this->qb_limit.' * FROM '.$table.$this->_compile_wh('qb_where').') DELETE FROM ci_delete';
		}

		return parent::_delete($table);
	}
642081
static void truncate(CallInfo callInfo, Table table) {
    final DB db = table.getDB();   
    db.access(callInfo, () -> {
      String sql = "TRUNCATE TABLE " + table.getName();
      table.setDirtyStatus(true);
      db.logSetup(callInfo, sql);
      try (WrappedStatement ws = db.compile(sql)) {
        ws.getStatement().execute();
      }
      return 0;
    });

  }
601383
public function dropExistingTable($table)
    {
        echo "    > drop table $table if exists ...";
        $time = microtime(true);
        $this->db->createCommand('DROP TABLE IF EXISTS `' . $table . '`')->execute();
        echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";
    }
361363
public function clearTable($table)
    {
        $this->query("DELETE FROM \"$table\"");

        // Check if resetting the auto-increment is needed
        $autoIncrement = $this->preparedQuery(
            'SELECT "AUTO_INCREMENT" FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?',
            [ $this->getSelectedDatabase(), $table]
        )->value();

        if ($autoIncrement > 1) {
            $this->query("ALTER TABLE \"$table\" AUTO_INCREMENT = 1");
        }
    }
1301646
protected function truncateTable()
    {
        $tableName = $this->entityMetadata->table['name'];
        $connection = $this->entityManager->getConnection();
        $query = $connection->getDatabasePlatform()->getTruncateTableSQL($tableName, true);
        $connection->executeQuery($query);
    }
1317240
public function delete($table = null)
    {
        $this->type = self::TYPE_DELETE;
        if ($table) {
            $this->table($table);
        }

        return $this;
    }
273740
public function deleteFrom($table){
        $obj  =  new DeleteRule(new Context($this->connection));
        return $obj->deleteFrom($table);
    }