Read MySQL BIT type
@param array $column
@return string
766682
protected function getBit(array $column)
    {
        $res = '';
        for ($byte = 0; $byte < $column['bytes']; ++$byte) {
            $current_byte = '';
            $data = $this->binaryDataReader->readUInt8();
            if (0 === $byte) {
                if (1 === $column['bytes']) {
                    $end = $column['bits'];
                } else {
                    $end = $column['bits'] % 8;
                    if (0 === $end) {
                        $end = 8;
                    }
                }
            } else {
                $end = 8;
            }

            for ($bit = 0; $bit < $end; ++$bit) {
                if ($data & (1 << $bit)) {
                    $current_byte .= '1';
                } else {
                    $current_byte .= '0';
                }

            }
            $res .= strrev($current_byte);
        }

        return $res;
    }
940546
public function getValue(string $column)
    {
        if ($column === 'id') return $this->id;
        return $this->data[$column]->getValue();
    }
645856
public function getColumnName( $column )
    {
        if ( $this->getColumnsUseTranslation() )
        {
            $column = $this->view->translate(
                $this->getColumnId( $column ),
                $this->getColumnTranslateTextDomain()
            );
        }

        return $column;
    }
368364
public static function filter($column){
        $column = wp_parse_args($column, [
            'type' => '',
            'null' => false,
        ]);
        // Type required.
        if( !self::exists($column['type']) ){
            throw new \Exception('You must properly specify the data type of column.');
        }
        // Check varchar length
        if( self::is_length_required($column['type']) && !isset($column['length']) ){
            throw new \Exception(sprintf('Column %s requires length property.', $column['type']));
        }
        // Signed or Unsigned?
        if( self::is_numeric($column['type']) ){
            $column['signed'] = isset($column['signed']) ? (bool)$column['signed'] : true;
        }
        // If decimal, test_required params
        if( $column['type'] == self::DECIMAL ){
            if( !isset($column['max_digit'], $column['float']) ){
                throw new \Exception(sprintf('Column %s requires max_digit and float property.', self::DECIMAL));
            }
        }
        // If enum or set, test required properties.
        if( self::is_set($column['type']) && ( !is_array($column['values']) || empty($column['values']) ) ){
            throw new \Exception(sprintf('Column %s requires values property as array.', $column['type']));
        }
        return $column;
    }
1094550
protected function prepareColumn(Column $column)
    {
        if ($column->getType() === SqlsrvType::FLOAT && strpos($column->getLength(), ',') !== false) {
            $column->length(24);
        }

        if ($column->getType() === SqlsrvType::DOUBLE && strpos($column->getLength(), ',') !== false) {
            $column->length(53);
        }

        if (in_array($column->getType(), [SqlsrvType::TEXT, SqlsrvType::LONGTEXT], true)) {
            $column->length('max');
        }

        $column = parent::prepareColumn($column);

        if (SqlsrvType::noLength($column->getType())) {
            $column->length(null);
        }

        return $column;
    }
505300
protected function _getIntegerColumn(Column\Integer $column)
    {

        if ($column->getAutoIncrement()) {
            $this->_disablePrimaryConstraint = true;
            return $column->getName().' INTEGER PRIMARY KEY AUTOINCREMENT';
        }

        $type = 'INTEGER';

        $default = '';
        if ($column->getDefault()) {
            $default = ' DEFAULT '.$column->getDefault();
        }

        return sprintf(
            '%s %s%s%s%s',
            $column->getName(),
            $type,
            $this->_columnLength($column),
            $this->_nullableColumn($column),
            $default
        );
    }
160956
protected function _getColumnKey($column)
    {
        if (!is_array($column)) {
            $matches = $this->_matchColumnString($column);
            $columnKey = $matches[1];
        } elseif (!empty($column['attribute'])) {
            $columnKey = $column['attribute'];
        } elseif (!empty($column['label'])) {
            $columnKey = $column['label'];
        } elseif (!empty($column['header'])) {
            $columnKey = $column['header'];
        } elseif (!empty($column['class'])) {
            $columnKey = $column['class'];
        } else {
            $columnKey = null;
        }
        return hash('crc32', $columnKey);
    }
301894
public function getSelectionAlias($column)
        {
            if (!is_numeric($column) && !is_string($column)) {
                if (is_array($column) && array_key_exists('column', $column)) {
                    $column = $column['column'];
                } else {
                    throw new Exception('Invalid column!');
                }
            }
            if (!isset($this->aliases[$column])) {
                $this->aliases[$column] = str_replace('.', '_', $column);
            }

            return $this->aliases[$column];
        }
274906
public function value( $column )
	{
		$result = $this->first( [$column] );

		return $result ? $result->{$column} : null;
	}
542859
protected function getDecimal(array $column)
    {
        $digitsPerInteger = 9;
        $compressedBytes = [0, 1, 1, 2, 2, 3, 3, 4, 4, 4];
        $integral = $column['precision'] - $column['decimals'];
        $unCompIntegral = (int)($integral / $digitsPerInteger);
        $unCompFractional = (int)($column['decimals'] / $digitsPerInteger);
        $compIntegral = $integral - ($unCompIntegral * $digitsPerInteger);
        $compFractional = $column['decimals'] - ($unCompFractional * $digitsPerInteger);

        $value = $this->binaryDataReader->readUInt8();
        if (0 !== ($value & 0x80)) {
            $mask = 0;
            $res = '';
        } else {
            $mask = -1;
            $res = '-';
        }
        $this->binaryDataReader->unread(pack('C', $value ^ 0x80));

        $size = $compressedBytes[$compIntegral];
        if ($size > 0) {
            $value = $this->binaryDataReader->readIntBeBySize($size) ^ $mask;
            $res .= $value;
        }

        for ($i = 0; $i < $unCompIntegral; ++$i) {
            $value = $this->binaryDataReader->readInt32Be() ^ $mask;
            $res .= sprintf('%09d', $value);
        }

        $res .= '.';

        for ($i = 0; $i < $unCompFractional; ++$i) {
            $value = $this->binaryDataReader->readInt32Be() ^ $mask;
            $res .= sprintf('%09d', $value);
        }

        $size = $compressedBytes[$compFractional];
        if ($size > 0) {
            $value = $this->binaryDataReader->readIntBeBySize($size) ^ $mask;
            $res .= sprintf('%0' . $compFractional . 'd', $value);
        }

        return bcmul($res, 1, $column['precision']);
    }
474991
public static function fromColumn(Db\Column $column)
    {
        $data = $column->toArray();
        if (isset($data['type']) && is_integer($data['type'])) {
            $data['type'] = self::getTypeName($data['type']);
        }
        if (isset($data['bindType']) && is_integer($data['bindType'])) {
            $data['bindType'] = self::getBindName($data['bindType']);
        }
        
        return new self($data);
    }
116677
protected function getColumnSqlDefinition(Column $column)
    {
        $buffer = [];
        if ($column->isIdentity()) {
            $buffer[] = $column->getType() == 'biginteger' ? 'BIGSERIAL' : 'SERIAL';
        } elseif ($column->getType() instanceof Literal) {
            $buffer[] = (string)$column->getType();
        } else {
            $sqlType = $this->getSqlType($column->getType(), $column->getLimit());
            $buffer[] = strtoupper($sqlType['name']);

            // integers cant have limits in postgres
            if (static::PHINX_TYPE_DECIMAL === $sqlType['name'] && ($column->getPrecision() || $column->getScale())) {
                $buffer[] = sprintf(
                    '(%s, %s)',
                    $column->getPrecision() ?: $sqlType['precision'],
                    $column->getScale() ?: $sqlType['scale']
                );
            } elseif (in_array($sqlType['name'], ['geography'])) {
                // geography type must be written with geometry type and srid, like this: geography(POLYGON,4326)
                $buffer[] = sprintf(
                    '(%s,%s)',
                    strtoupper($sqlType['type']),
                    $sqlType['srid']
                );
            } elseif (in_array($sqlType['name'], ['time', 'timestamp'])) {
                if (is_numeric($column->getPrecision())) {
                    $buffer[] = sprintf('(%s)', $column->getPrecision());
                }

                if ($column->isTimezone()) {
                    $buffer[] = strtoupper('with time zone');
                }
            } elseif (!in_array($sqlType['name'], ['integer', 'smallint', 'bigint', 'boolean'])) {
                if ($column->getLimit() || isset($sqlType['limit'])) {
                    $buffer[] = sprintf('(%s)', $column->getLimit() ?: $sqlType['limit']);
                }
            }
        }

        $buffer[] = $column->isNull() ? 'NULL' : 'NOT NULL';

        if (!is_null($column->getDefault())) {
            $buffer[] = $this->getDefaultValueDefinition($column->getDefault(), $column->getType());
        }

        return implode(' ', $buffer);
    }
133098
protected function getColumnSqlDefinition(Column $column)
    {
        if ($column->getType() instanceof Literal) {
            $def = (string)$column->getType();
        } else {
            $sqlType = $this->getSqlType($column->getType(), $column->getLimit());
            $def = strtoupper($sqlType['name']);
        }
        if ($column->getPrecision() && $column->getScale()) {
            $def .= '(' . $column->getPrecision() . ',' . $column->getScale() . ')';
        } elseif (isset($sqlType['limit'])) {
            $def .= '(' . $sqlType['limit'] . ')';
        }
        if (($values = $column->getValues()) && is_array($values)) {
            $def .= "('" . implode("', '", $values) . "')";
        }
        $def .= $column->getEncoding() ? ' CHARACTER SET ' . $column->getEncoding() : '';
        $def .= $column->getCollation() ? ' COLLATE ' . $column->getCollation() : '';
        $def .= (!$column->isSigned() && isset($this->signedColumnTypes[$column->getType()])) ? ' unsigned' : '';
        $def .= ($column->isNull() == false) ? ' NOT NULL' : ' NULL';
        $def .= $column->isIdentity() ? ' AUTO_INCREMENT' : '';
        $def .= $this->getDefaultValueDefinition($column->getDefault(), $column->getType());

        if ($column->getComment()) {
            $def .= ' COMMENT ' . $this->getConnection()->quote($column->getComment());
        }

        if ($column->getUpdate()) {
            $def .= ' ON UPDATE ' . $column->getUpdate();
        }

        return $def;
    }
874951
public static function hasColumn($column)
    {
        $cls  = get_called_class();
        $key  = null;
        $keys = self::$_columns[$cls];

        foreach ($keys as $ckey) {
            $col1 = self::isIgnoringCase() ? strtolower($ckey)   : $ckey;
            $col2 = self::isIgnoringCase() ? strtolower($column) : $column;
            if ($col1==$col2) {
                $key = $ckey;
                break;
            }
        }
        return $key;
    }
12286
public function getBinaryTypeDeclarationSQL(array $field)
    {
        if (! isset($field['length'])) {
            $field['length'] = $this->getBinaryDefaultLength();
        }

        $fixed = $field['fixed'] ?? false;

        $maxLength = $this->getBinaryMaxLength();

        if ($field['length'] > $maxLength) {
            if ($maxLength > 0) {
                @trigger_error(sprintf(
                    'Binary field length %d is greater than supported by the platform (%d). Reduce the field length or use a BLOB field instead.',
                    $field['length'],
                    $maxLength
                ), E_USER_DEPRECATED);
            }

            return $this->getBlobTypeDeclarationSQL($field);
        }

        return $this->getBinaryTypeDeclarationSQLSnippet($field['length'], $fixed);
    }
288186
protected function getColumnSqlDefinition(Column $column)
    {
        $buffer = [];
        if ($column->isIdentity()) {
            $buffer[] = $column->getType() === 'biginteger' ? 'BIGSERIAL' : 'SERIAL';
        } else {
            $sqlType = $this->getSqlType($column->getType(), $column->getLimit());
            $buffer[] = \strtoupper($sqlType['name']);
            // integers cant have limits in postgres
            if (static::PHINX_TYPE_DECIMAL === $sqlType['name'] && ($column->getPrecision() || $column->getScale())) {
                $buffer[] = \sprintf(
                    '(%s, %s)',
                    $column->getPrecision() ?: $sqlType['precision'],
                    $column->getScale() ?: $sqlType['scale']
                );
            } elseif ($sqlType['name'] === 'geography') {
                // geography type must be written with geometry type and srid, like this: geography(POLYGON,4326)
                $buffer[] = \sprintf(
                    '(%s,%s)',
                    \strtoupper($sqlType['type']),
                    $sqlType['srid']
                );
            } elseif (!\in_array($sqlType['name'], ['integer', 'smallint', 'bigint'], true)) {
                if ($column->getLimit() || isset($sqlType['limit'])) {
                    $buffer[] = sprintf('(%s)', $column->getLimit() ?: $sqlType['limit']);
                }
            }

            $timeTypes = [
                'time',
                'timestamp',
            ];
            if (in_array($sqlType['name'], $timeTypes) && $column->isTimezone()) {
                $buffer[] = strtoupper('with time zone');
            }
        }

        $buffer[] = $column->isNull() ? 'NULL' : 'NOT NULL';

        if (null !== $column->getDefault()) {
            $buffer[] = $this->getDefaultValueDefinition($column->getDefault());
        }

        return implode(' ', $buffer);
    }
432160
public function type(int $row, int $column)
    {
        $file = $this->getData($row, $column);

        if ($file == null) {
            return null;
        }

        $file = rtrim($file, DIRECTORY_SEPARATOR);
        $file = $this->rootPath . DIRECTORY_SEPARATOR . $file;

        $fileType = filetype($file);

        if ($fileType != 'file') {
            return $fileType;
        }

        return mime_content_type($file);
    }