Tworzy lub aktualizuje pole query
@param string $tableName
353014
protected static function _updateQueryField($tableName)
    {
        //prefixy nazw
        $queryClassName = self::_getNamespace($tableName) . '\\' . self::_getNamePrefix($tableName) . 'Query';
        //odczyt struktury
        $structure = DbConnector::getTableStructure($tableName);
        $methods = '';
        //budowanie komentarzy do metod
        foreach ($structure as $fieldName => $fieldDetails) {
            $fieldName = ucfirst(Convert::underscoreToCamelcase($fieldName));
            //metody equalsColumn... np. equalsColumnActive()
            $methods .= ' * @method \\' . $queryClassName . ' equalsColumn' . $fieldName . '()' . "\n";
            //notEqualsColumn
            $methods .= ' * @method \\' . $queryClassName . ' notEqualsColumn' . $fieldName . '()' . "\n";
            //greaterThanColumn
            $methods .= ' * @method \\' . $queryClassName . ' greaterThanColumn' . $fieldName . '()' . "\n";
            //lessThanColumn
            $methods .= ' * @method \\' . $queryClassName . ' lessThanColumn' . $fieldName . '()' . "\n";
            //greaterOrEqualsColumn
            $methods .= ' * @method \\' . $queryClassName . ' greaterOrEqualsColumn' . $fieldName . '()' . "\n";
            //lessOrEqualsColumn
            $methods .= ' * @method \\' . $queryClassName . ' lessOrEqualsColumn' . $fieldName . '()' . "\n";
        }
        //anotacje dla metod porównujących (equals itp.)
        $queryCode = '<?php' . "\n\n" .
            'namespace ' . self::_getNamespace($tableName) . '\QueryHelper' . ";\n\n" .
            '/**' . "\n" .
            ' * @method \\' . $queryClassName . ' equals($value)' . "\n" .
            ' * @method \\' . $queryClassName . ' notEquals($value)' . "\n" .
            ' * @method \\' . $queryClassName . ' greater($value)' . "\n" .
            ' * @method \\' . $queryClassName . ' less($value)' . "\n" .
            ' * @method \\' . $queryClassName . ' greaterOrEquals($value)' . "\n" .
            ' * @method \\' . $queryClassName . ' lessOrEquals($value)' . "\n" .
            ' * @method \\' . $queryClassName . ' like($value)' . "\n" .
            ' * @method \\' . $queryClassName . ' notLike($value)' . "\n" .
            ' * @method \\' . $queryClassName . ' between($from, $to)' . "\n" .
            $methods .
            ' */' . "\n" .
            'class ' . ($className = self::_getNamePrefix($tableName) . 'QueryField') . ' extends \Mmi\Orm\QueryHelper\QueryField' .
            "\n{" .
            "\n\n" .
            '}' . "\n";
        //zapis pliku
        file_put_contents(self::_mkdirRecursive(self::_getPathPrefix($tableName) . '/QueryHelper') . '/' . $className . '.php', $queryCode);
    }
1321993
protected static function checkColumn($tableName, $columnName, $con=NULL)
    {
        $connection = self::checkConnection($con);

            $result = $connection->prepare("SELECT {$columnName} FROM {$tableName}");
            $result->execute();
            if (! $result->columnCount())
            {
                throw new ColumnNotExistExeption();
            }
            return $columnName;
    }
501964
public function handle(string $tableName)
    {
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);
        $recordData = GeneralUtility::makeInstance(RecordData::class);

        // First insert an empty row and get the uid of this row since
        // some fields need this uid for relations later.
        $fieldValues = [
            'pid' => $recordFinder->findPidOfMainTableRecord($tableName),
        ];
        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($tableName);
        $connection->insert($tableName, $fieldValues);
        $fieldValues['uid'] = $connection->lastInsertId($tableName);
        $fieldValues = $recordData->generate($tableName, $fieldValues);
        $connection->update(
            $tableName,
            $fieldValues,
            [ 'uid' => $fieldValues['uid'] ]
        );

        $this->generateTranslatedRecords($tableName, $fieldValues);
    }
1370587
public function tableExists($tableName) {
        $tables = $this->query("SHOW TABLES");
        foreach ($tables as $k => $table) {
            $key = 'Tables_in_' . $this->config['table'];
            if (strtolower($table[$key]) == strtolower($this->getPrefix() . $tableName)) {
                return TRUE;
            }
        }
        return FALSE;
    }
653637
public function hasField($tableName, $fieldName)
    {
        if (!$this->hasTable($tableName)) {
            return false;
        }
        $fields = $this->fieldList($tableName);
        return array_key_exists($fieldName, $fields);
    }
431971
public function handle(string $tableName)
    {
        /** @var RecordFinder $recordFinder */
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);

        // tx_styleguide_staticdata is used in other TCA demo fields. We need some default
        // rows to later connect other fields to these rows.
        $pid = $recordFinder->findPidOfMainTableRecord('tx_styleguide_staticdata');
        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_styleguide_staticdata');
        $connection->bulkInsert(
            'tx_styleguide_staticdata',
            [
                [ $pid, 'foo' ],
                [ $pid, 'bar' ],
                [ $pid, 'foofoo' ],
                [ $pid, 'foobar' ],
            ],
            [ 'pid', 'value_1' ]
        );
    }
788526
public function findTableInArray($tablename) {
        foreach ($this->tables as $i => $table) {
            if ($tablename == $table->getName()) {
                return $i;
            }
        }
        return null;
    }
1043413
protected function isOneToMany($tableName, $columnName)
    {
        $query = $this->getRelationTypeQuery($tableName, $columnName);
        $result = DB::select($query);

        return isset($result[0]);
    }
1326971
public function getTableWhere($tableName)
    {
        if (!empty($this->tableWheres[$tableName])) {
            return $this->tableWheres[$tableName];
        } elseif ($this->dumpSettings['where']) {
            return $this->dumpSettings['where'];
        }

        return false;
    }
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));
  }
537418
protected static function buildClause($tableName, $data)
    {
        $counter = 0;
        $updateQuery = "";
        $arraySize = count($data);

        foreach ($data as $key => $value)
        {
            $counter++;
            $columnName = self::checkColumn($tableName, self::sanitize($key));
            $updateQuery .= $columnName ." = '".self::sanitize($value)."'";
            if ($arraySize > $counter)
            {
                $updateQuery .= ", ";
            }
        }
        return $updateQuery;
    }
1213177
public function update($tableName)
    {
        $sql = new Update($tableName);
        $sql->setAdapter($this->_adapter);
        return $sql;
    }
294862
public function getFields($tableName)
    {
        list($tableName) = explode(' ', $tableName);

        if (false === strpos($tableName, '`')) {
            if (strpos($tableName, '.')) {
                $tableName = str_replace('.', '`.`', $tableName);
            }
            $tableName = '`' . $tableName . '`';
        }

        $sql    = 'SHOW COLUMNS FROM ' . $tableName;
        $pdo    = $this->query($sql, [], false, true);
        $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
        $info   = [];

        if ($result) {
            foreach ($result as $key => $val) {
                $val                 = array_change_key_case($val);
                $info[$val['field']] = [
                    'name'    => $val['field'],
                    'type'    => $val['type'],
                    'notnull' => (bool) ('' === $val['null']), // not null is empty, null is yes
                    'default' => $val['default'],
                    'primary' => (strtolower($val['key']) == 'pri'),
                    'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
                ];
            }
        }

        return $this->fieldCase($info);
    }
299566
protected final function _prepareOrder($fieldName, $tableName = null, $asc = true)
    {
        //jeśli pusty order - dodawanie ORDER BY na początku
        if (!$this->_compile->order) {
            $this->_compile->order = 'ORDER BY ';
        } else {
            $this->_compile->order .= ', ';
        }
        $this->_compile->order .= $this->_prepareField($fieldName, $tableName) . ' ' . ($asc ? 'ASC' : 'DESC');
        return $this;
    }
635567
protected static function _getPathPrefix($tableName)
    {
        $table = explode('_', $tableName);
        //klasy leżą w plikach w /Orm/
        $baseDir = BASE_PATH . '/src/' . ucfirst($table[0]) . '/Orm';
        return $baseDir;
    }
1081495
public function tableSize(string $tableName)
    {
        $tables = $this->tablesSize();

        if (isset($tables[$tableName])) {
            return $tables[$tableName];
        }

        return null;
    }
772348
protected function _getColumns($tableName)
    {

        $params = [
            ':schemaName' => $this->_adapter->getSchemaName(),
            ':tableName' => $tableName
        ];
        return $this->_adapter->query($this->_getColumnsSql, $params);
    }