根据表名删除数据 这个操作太危险慎用。不过一般情况程序也没这个权限

@param string $tableName 要清空的表名

@return bool
345701
public function truncate($tableName)
    {
        $tableName = $this->tablePrefix . $tableName;
        $this->currentQueryIsMaster = true;
        $stmt = $this->prepare("TRUNCATE {$tableName}");

        $this->setCacheVer($tableName);
        return $stmt->execute();//不存在会报错，但无关紧要
    }
395409
public function getTableDescription($tableName)
    {
        // simple cache
        if (!isset(self::$tblDescCache[$tableName])) {
            self::$tblDescCache[$tableName] = $this->fetchTableDescription($tableName);
        }

        return self::$tblDescCache[$tableName];
    }
1228569
protected function normalizeFieldName($tableName)
    {
        $tableName = Text::camelCaseToSeparator($tableName, '#');
        $parts = explode('#', $tableName);
        $lastName = array_pop($parts);
        $lastName = Text::singular(strtolower($lastName));
        array_push($parts, ucfirst($lastName));
        return lcfirst(implode('', $parts));
    }
1032982
public function deleteTable($tableName)
    {
        try {
            $this->db->deleteTable($tableName);
        } catch (\Exception $e) {
            throw new DbException($e->getMessage());
        }
    }
451795
public function checkTableExists(string $tableName): bool
    {
        try {
            $result = $this->pdo->query("SELECT 1 FROM $tableName LIMIT 1");
        } catch (\Exception $e) {
            return false;
        }

        return $result !== false;
    }
414866
public function dropTable($tableName)
    {
        $tableName = $this->getFullQualifiedAssetName($tableName);
        $this->getTable($tableName);
        unset($this->_tables[$tableName]);

        return $this;
    }
732753
public function getTableInfo($tableName, $fetch = '')
    {
        if (is_array($tableName)) {
            $tableName = key($tableName) ?: current($tableName);
        }

        if (strpos($tableName, ',')) {
            // 多表不获取字段信息
            return false;
        } else {
            $tableName = $this->parseSqlTable($tableName);
        }

        $guid = md5($tableName);
        if (!isset(self::$info[$guid])) {
            $mongoQuery = new MongoQuery([], ['limit' => 1]);

            $cursor = $this->query($tableName, $mongoQuery, null, true, ['root' => 'array', 'document' => 'array']);

            $resultSet = $cursor->toArray();
            $result    = isset($resultSet[0]) ? (array) $resultSet[0] : [];
            $fields    = array_keys($result);
            $type      = [];

            foreach ($result as $key => $val) {
                // 记录字段类型
                $type[$key] = getType($val);
                if ('_id' == $key) {
                    $pk = $key;
                }
            }

            if (!isset($pk)) {
                // 设置主键
                $pk = null;
            }

            $result = ['fields' => $fields, 'type' => $type, 'pk' => $pk];

            self::$info[$guid] = $result;
        }

        return $fetch ? self::$info[$guid][$fetch] : self::$info[$guid];
    }
1041594
public function tableExists($tableName, $connectionName = 'default')
    {
        try {
            $db = ConnectionManager::get($connectionName);
            $collection = $db->schemaCollection();
            $tables = $collection->listTables();
            if (in_array($tableName, $tables)) {
                return true;
            }
        } catch (PDOException $connectionError) {
            return false;
        }
        return false;
    }
1032877
public function getTableUses($tablename) {

        $uses = array();

        // Check if some foreign key in the whole structure is using it
        // (by comparing the reftable with the tablename)
        if ($this->tables) {
            foreach ($this->tables as $table) {
                $keys = $table->getKeys();
                if ($keys) {
                    foreach ($keys as $key) {
                        if ($key->getType() == XMLDB_KEY_FOREIGN) {
                            if ($tablename == $key->getRefTable()) {
                                $uses[] = 'table ' . $table->getName() . ' key ' . $key->getName();
                            }
                        }
                    }
                }
            }
        }

        // Return result
        if (!empty($uses)) {
            return $uses;
        } else {
            return false;
        }
    }
977552
public function generateTableName($tableName)
    {
        if (!$this->useTablePrefix) {
            return $tableName;
        }

        $db = $this->getDbConnection();
        if (preg_match("/^{$db->tablePrefix}(.*?)$/", $tableName, $matches)) {
            $tableName = '{{%' . $matches[1] . '}}';
        } elseif (preg_match("/^(.*?){$db->tablePrefix}$/", $tableName, $matches)) {
            $tableName = '{{' . $matches[1] . '%}}';
        }
        return $tableName;
    }
1106351
protected function tableExist($tableName)
    {
        /** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $sm */
        $sm = $this->dbHandler->getConnection()->getSchemaManager();
        foreach ($sm->listTables() as $table) {
            if ($table->getName() == $tableName) {
                return true;
            }
        }

        return false;
    }
877751
public function tablesExist($tableNames)
    {
        $tableNames = array_map('strtolower', (array) $tableNames);

        return count($tableNames) === count(array_intersect($tableNames, array_map('strtolower', $this->listTableNames())));
    }
892513
public static function tableExists($tableName)
    {
        $query = "SELECT 1 FROM $tableName LIMIT 1";

        try {
            $result = Connection::db()->query($query);
        } catch (Exception $e) {
            return false;
        }

        return $result !== false;
    }
206153
public function unlock(string $tableName): void
    {
        // 连接数据库
        $connect = $this->connect($tableName);

        // 解锁表
        $connect->exec('unlock tables ');

        // 重新设置为自动提交
        $connect->setAttribute(\PDO::ATTR_AUTOCOMMIT, true);
    }
37785
public static function checkTableExists(string $tableName): bool
  {
    $query = sprintf('
select 1
from   information_schema.TABLES
where table_schema = database()
and   table_name   = %s', self::$dl->quoteString($tableName));

    return !empty(self::executeSingleton0($query));
  }
741997
public function setTableName($tableName) {
        $this->query = str_replace($this->tableName, $tableName, $this->query);
        $this->dummyQuery = str_replace($this->tableName, $tableName, $this->dummyQuery);
        $this->tableName = $tableName;
        return $this;
    }
572116
public function setTableName($tableName)
    {
        if (trim($tableName) == '') {
            $tableName = null;
        }
        $this->tableName = $tableName;

        return $this;
    }