Returns the ID of a column (db.table.column)

@param string $col The table's column (can include the table)
@param type $table The table
@return string
778321
public function col_id($col, $table=false){
    
    if ( substr_count($col, ".") === 2 ){
      return $col;
    }
    else if ( substr_count($col, ".") === 1 ){
      if ( $table ){
        return $this->table_id($table).'.'.$this->simple_name($col);
      }
      else{
        return $this->simple_name($this->client_db).'.'.$col;
      }
    }
    else if ( $table ){
      return $this->table_id($table).'.'.$col;
    }
  }
132760
public function findForeignKeys ($table, $column = null)
		{
			$query = ( new  Query )
				->select('CONSTRAINT_NAME')
				->from('INFORMATION_SCHEMA.KEY_COLUMN_USAGE')
				->where([
					'TABLE_SCHEMA' => $this->getDbName(),
					'TABLE_NAME'   => $table
				]);
			if (!is_null($column))
				$query->andWhere([ 'COLUMN_NAME' => $column ]);

			return $query->column();
		}
520281
public function table_id($table, $db=false){
    if ( substr_count($table, ".") === 1 ){
      return $table;
    }
    else {
      return ( $db ?: $this->client_db ).'.'.$table;
    }
  }
882996
public function lastInsertId($table = null, $column = null)
    {
        $this->connect();

        return $this->_connection->lastInsertId($table);
    }
320636
public function insert_id($table = '')
    {
        if (!$this->db_connected || $this->db_mode == 'r') {
            return false;
        }

        if ($table) {
            // resolve table name
            $table = $this->table_name($table);
        }

        $id = $this->dbh->lastInsertId($table);

        return $id;
    }
1263205
public function getColumnDDL(Column $col)
	{
		$domain = $col->getDomain();
		
		$ddl = array($this->quoteIdentifier($col->getName()));
		$sqlType = $domain->getSqlType();
		if ($this->hasSize($sqlType)) {
			$ddl []= $sqlType . $domain->printSize();
		} else {
			$ddl []= $sqlType;
		}
		if ($default = $this->getColumnDefaultValueDDL($col)) {
			$ddl []= $default;
		}
		if ($notNull = $this->getNullString($col->isNotNull())) {
			$ddl []= $notNull;
		}
		if ($autoIncrement = $col->getAutoIncrementString()) {
			$ddl []= $autoIncrement;
		}

		return implode(' ', $ddl);
	}
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);
    }
1197921
protected function cols($table, Connection $db)
    {
        $c = array();
        foreach ($db->fetchAll("SHOW COLUMNS FROM `$table`") as $row) {
            $c[$row['Field']] = $row['Type'];
        }
        return $c;
    }
823813
public static function getFullColumnName($column, $table = null)
    {
        // Get target table name
        if ($table === null) {
            // Make sure, the getTableName() is defined in calling class
            if (method_exists(get_called_class(), 'getTableName')) {
                $table = static::getTableName();
            } else {
                throw new LogicException(
                    sprintf('The method getTableName() is not declared in %s, therefore a full column name cannot be generated', get_called_class())
                );
            }
        }

        return sprintf('%s.%s', $table, $column);
    }
629747
public function getColumnsLabel($columns, $table)
    {
        /** @var \yii\db\ActiveRecord $model */
        $model = $this->_currentModel;
        /** @var Module $module */
        $module = $this->module;
        $attributeLabels = $model->attributeLabels();
        $relations = $module->tables[$table]['relations'];
        $columnsLabel = [];
        foreach ($columns as $attribute) {
            if (isset($attributeLabels[$attribute])) {
                $columnsLabel[] = $attributeLabels[$attribute];
            } elseif (isset($relations[$attribute]['label'])) {
                $columnsLabel[] = $relations[$attribute]['label'];
            } else {
                $columnsLabel[] = $attribute;
            }
        }

        return $columnsLabel;
    }
697407
public function id($column = 'id')
    {
        $this->int($column)->unsigned()->autoIncrement();

        return $this->primary($column);
    }
1028259
int getElementID(int column) {
        if (cells[column] == null) return NULL;
        else if (Cell.class.isInstance(cells[column])) return CELL;
        else if (Table.class.isInstance(cells[column])) return TABLE;
        
        return -1;
    }
1070137
protected function getColumnSQLDeclaration(Column $column)
    {
        $columnDeclaration = $column->getName().' '.$column->getType()->getSQLDeclaration($this, $column->toArray());

        if ($column->isNotNull()) {
            $columnDeclaration .= ' NOT NULL';
        }

        if ($column->getDefault() !== null) {
            $default = $column->getType()->convertToDatabaseValue($column->getDefault(), $this);
            $columnDeclaration .= ' DEFAULT '.$this->quote($default);
        }

        if ($this->supportInlineColumnComments()
            && ($this->hasCustomType($column->getType()->getName())
            || ($column->getComment() !== null))
        ) {
            $columnDeclaration .= ' COMMENT '.$this->getColumnCommentSQLDeclaration($column);
        }

        return $columnDeclaration;
    }
1247362
public function hasColumn($table, $column)
    {
        $column = strtolower($column);

        return in_array($column, array_map('strtolower', $this->getColumnListing($table)));
    }
222019
public function lastInsertId(string $table, string $column = 'id')
    {
        $databaseServer = $this->connection->getDatabasePlatform()->getName();
        if (isset($this->databaseSpecificHelpers[$databaseServer])) {
            return $this->databaseSpecificHelpers[$databaseServer]
                ->lastInsertId($table, $column);
        }

        return $this->connection->lastInsertId($table);
    }
426994
public function getEntityField($table, $column)
    {
        $class = $this->getEntityClass($table);
        /** @var Entity $entity */
        $entity = new $class;
        $reflection = $entity->getReflection($this);
        foreach ($reflection->getEntityProperties() as $property) {
            if ($property->getColumn() == $column) {
                return Utils::underscoreToCamel($property->getName());
            }
        }
        throw new InvalidArgumentException(sprintf("Could not find property for table '%s' and column '%s'", $table, $column));
    }
804755
public function hasColumn ($table, $column)
		{
			$schema = $this->db->getTableSchema($table);

			return isset($schema->columns[ $column ]);
		}