Create an object name that limits to 30 chars.

@param  string $prefix
@param  string $table
@param  string $col
@param  string $type
@return string
163548
private function createObjectName($prefix, $table, $col, $type)
    {
        // max object name length is 30 chars
        return substr($prefix . $table . '_' . $col . '_' . $type, 0, 30);
    }
1081640
public function addColumn( $table, $name, $type )
    {
        return $this->handler->addColumn( $table, $name, $type );
    }
1177916
private function makeSql(int $type, string $sql, int $count): string
    {
        switch ($type) {
            case self::TYPE_FUNCTION_QUERY:
                $limit = $count !== self::UNLIMIT ? sprintf('limit %s', $count) : '';
                $result = vsprintf('select * from %s %s', [$sql, $limit,]);
                break;
            case self::TYPE_FUNCTION_CURSOR:
                $fetch = $count === self::UNLIMIT ? 'all' : 'FORWARD ' . $count;
                $result = vsprintf('select %s; fetch %s from _result;', [$sql, $fetch,]);
                break;
            case self::TYPE_SIMPLE_QUERY:
            default:
                $result = $sql;
        }

        return $result;
    }
789797
public function table_name($table, $quoted = false)
    {
        // let plugins alter the table name (#1489837)
        $plugin = rcube::get_instance()->plugins->exec_hook('db_table_name', array('table' => $table));
        $table = $plugin['table'];

        // add prefix to the table name if configured
        if (($prefix = $this->options['table_prefix']) && strpos($table, $prefix) !== 0) {
            $table = $prefix . $table;
        }

        if ($quoted) {
            $table = $this->quote_identifier($table);
        }

        return $table;
    }
1303748
public function prefixColumn($column)
    {
        $table_names = $this->tableNames();
        if (count(
                        array_filter($table_names, function ($value) use (&$column) {
                            return strpos($column, $value . '.') === 0;
                        })
                )) {
            // the column starts with one of the table names
            $column = $this->prefix . $column;
        }

        return $column;
    }
514849
public function replacePrefix($sql, $prefix = '#__')
	{
		// As we replace strings of different lengths, subsequent prefix positions will become invalid.
		// Thus, we track that differential here to account for the shifting locations
		$differential = strlen($this->tablePrefix) - strlen($prefix);
		$count        = 0;

		foreach (Str::findLiteral($prefix, $sql) as $prefixPosition)
		{
			$sql = substr_replace($sql, $this->tablePrefix, $prefixPosition + ($differential*$count), strlen($prefix));
			$count++;
		}

		return $sql;
	}
582782
private function apply_prefix( $prefix_type, $name ) {

		switch( $prefix_type ) {
			case 'network' :
				return $this->network_prefix . $name;
			case 'site' :
				return $this->site_prefix . $name;
		}

		throw new InvalidTableSchema( "Unknown prefix type: {$prefix_type}" );
	}
1248238
public static function getNaming($name, $prePostFix, $type = 'prefix', $symbol = '_')
    {
        if ($type == 'prefix') {
            return static::toCamelCase($prePostFix.$symbol.$name, $symbol);
        } else if ($type == 'postfix') {
            return static::toCamelCase($name.$symbol.$prePostFix, $symbol);
        }

        return null;
    }
1299997
private function getPrimaryKey(string $prefix, string $table): ?string
    {
        if (!$this->driver instanceof PostgresDriver) {
            throw new BuilderException('Postgres InsertQuery can be used only with Postgres driver and compiler');
        }

        return $this->driver->getPrimary($prefix, $table);
    }
20292
public function col_full_name($col, $table='', $escaped=false)
  {
    if ( \is_string($col) && ($col = trim($col)) ){
      $mcol = explode(".", str_replace("`", "", $col));
      if ( \count($mcol) > 1 ){
        $col = array_pop($mcol);
        $table = array_pop($mcol);
        $ok = 1;
      }
      else if ( !empty($table) ){
        $table = $this->table_simple_name($table);
        $col = end($mcol);
        $ok = 1;
      }
      if ( isset($ok) && bbn\str::check_name($table, $col) ){
        return $escaped ? "`".$table."`.`".$col."`" : $table.".".$col;
      }
    }
		return false;
  }
720569
final public function join($table, $cond, $type = 'LEFT')
    {

        if ($type != '') {
            $type = strtoupper(trim($type));

            if (!in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'))) {
                $type = '';
            } else {
                $type .= ' ';
            }
        }
        // Extract any aliases that might exist.  We use this information
        // in the _protect_identifiers to know whether to add a table prefix
        $this->traceTableAlias($table);

        // Strip apart the condition and protect the identifiers
        if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match)) {
            $match[1] = $this->identifiers($match[1]);
            $match[3] = $this->identifiers($match[3]);

            $cond = $match[1] . $match[2] . $match[3];
        }
        // Assemble the JOIN statement
        $join = $type . 'JOIN ' . $this->identifiers($table) . ' ON ' . $cond;

        $this->arrayJoin[] = $join;
        if ($this->arrayCaching === TRUE) {
            $this->arrayCacheJoin[] = $join;
            $this->arrayCacheExists[] = 'join';
        }

        return $this;
    }
854068
private int lengthOfTypePrefix(int type) {
        int length;
        switch (type) {
            case EmailRecipientUtils.BCC:
                length = 4;
                break;
            case EmailRecipientUtils.CC:
                length = 3;
                break;
            case EmailRecipientUtils.TO:
                length = 0;
                break;
            default:
                throw new IllegalArgumentException("Unknown type prefix: " + type);
        }
        return length;
    }
608232
private function createIndex(Table $table, array $columns)
    {
        if (count($columns) > 0) {
            $indexPrefix = "idx_" . RdsDeliveryExecutionService::TABLE_NAME . "_";

            // Index names are limited to 63 characters in PostgreSQL (64 in MySQL)
            $indexName = substr($indexPrefix . implode("_", $columns), 0, 63);

            $table->addIndex($columns, $indexName);
        }
    }
888959
public function createField($column, $attributes, $type = 'add')
    {
        $results = "\t\t\t".'$table';

        foreach ($attributes as $key => $field) {
            if (in_array($column, $this->relationshipKeys)) {
                $results .= $this->addRelationColumn($key, $field, $column);
            } else {
                $results .= $this->{"{$type}Column"}($key, $field, $column);
            }
        }

        return $results .= ';'.PHP_EOL;
    }
355163
public static function createForeignKeyName($table, $columns, $refTable)
    {
        $column = is_array($columns) ? implode('_', $columns) . '_' : '';
        return preg_replace('/[^\w_-]/', '', "FK_{$table}_{$column}{$refTable}");
    }
1347715
public static function serialize($prefix, array $typoscript, $indent = 0)
    {
        $serialized = [];

        // Sort the TypoScript fragment
        ksort($typoscript, SORT_NATURAL);

        // Run through the TypoScript fragment
        foreach ($typoscript as $key => $value) {
            $line = str_repeat(' ', $indent * 4);
            $line .= trim(strlen($prefix) ? "$prefix.$key" : $key, '.');

            // If the value is a list of values
            if (is_array($value)) {

                // If the list has only one element
                if (count($value) === 1) {
                    $line .= '.'.self::serialize('', $value, 0);
                } else {
                    $line .= ' {'.PHP_EOL.self::serialize('', $value, $indent + 1).PHP_EOL.'}';
                }

                // Else if it's a multiline value
            } elseif (preg_match('/\R/', $value)) {
                $line .= ' ('.PHP_EOL.$value.PHP_EOL.')';

                // Else: Simple assignment
            } else {
                $line .= ' = '.$value;
            }
            $serialized[] = $line;
        }

        return implode(PHP_EOL, $serialized);
    }
565270
public function insertQuery(string $prefix, string $table = null): InsertQuery
    {
        return new InsertQuery($this, $this->getCompiler($prefix), $table);
    }