Add a column mapping

@param ColumnMap       $local   The local column
@param ColumnMap|mixed $foreign The foreign column or value
977472
public function addColumnMapping(ColumnMap $local, $foreign)
    {
        $this->localColumns[] = $local;

        if ($foreign instanceof ColumnMap) {
            $this->foreignColumns[] = $foreign;
            $this->localValues[] = null;
        } else {
            $this->localValues[] = $foreign;
            $this->foreignColumns[] = null;
        }
    }
11351
public function join($foreign, $on, $joinType = Joins::INNER)
    {
        $builder = $this->getJoinStatement()->getBuilder();
        $foreign = is_array($foreign) ? $foreign : [$foreign];
        $foreign[0] = !($foreign[0] instanceof Expression) ? new Table($foreign[0]) : $foreign[0];
        
        $foreign = $builder->completeExpression(...$foreign);
        
        if (is_array($on)) {
            $whereOn = new Statement\Where($builder);
            $on = count($on) === count($on, true) ? [$on] : $on;
            
            foreach ($on as $criteria) {
                list($criteria[0], $criteria[1]) = [
                    ($criteria[0] instanceof Expression) ? $criteria[0] : $builder->createColumn($criteria[0]),
                    ($criteria[1] instanceof Expression) ? $criteria[1] : $builder->createColumn($criteria[1]),
                ];
                $whereOn->where(...$criteria);
            }
            
            $on = $whereOn;
        }
        
        $this->addJoin($foreign, $on, $joinType);
        
        return $this;
    }
994668
private function appendMapping(QueryBuilder $queryBuilder, MappingInterface $mapping, $locale, $locales)
    {
        if ($mapping->onlyPublished()) {
            $queryBuilder->andWhere(
                $this->qomFactory->comparison(
                    $this->qomFactory->propertyValue(
                        'node',
                        $this->propertyEncoder->localizedSystemName('state', $locale)
                    ),
                    '=',
                    $this->qomFactory->literal(WorkflowStage::PUBLISHED)
                )
            );
        }

        $properties = $mapping->getProperties();
        foreach ($properties as $propertyName) {
            $this->appendSingleMapping($queryBuilder, $propertyName, $locales);
        }

        if ($mapping->resolveUrl()) {
            $this->appendUrlMapping($queryBuilder, $locales);
        }
    }
922437
public JdbcMapperBuilder<T> addMapping(final String column, final int index, final int sqlType) {
        addMapping(column, index, sqlType, FieldMapperColumnDefinition.<JdbcColumnKey>identity());
        return this;
    }
120667
protected function insertBelongsTo(Model $record, Relation $relation, $columnValue)
    {
        $foreignKeyName = $relation->getForeignKey();
        list($table, $label) = $this->parseRecordLabel($columnValue);
        $foreignKeyValue = $this->generateKey($label, $table);
        $record->$foreignKeyName = $foreignKeyValue;
    }
412390
protected function fetchOneToMany($foreign_class, $foreign_column, $column)
    {
        return $foreign_class::select($this->connection)
            ->where($foreign_column, '=', $this->getRaw($column))
            ->execute();
    }
185392
public function property(string $memberExpression) : ColumnMappingDefiner
    {
        $this->memberParser->parse($this->class, $memberExpression);

        return new ColumnMappingDefiner(
            function (IColumn $column) use ($memberExpression) {
                $this->column($column);
                $this->propertyComponentIdMap[$memberExpression] = $column->getComponentId();
            },
            function ($componentId) use ($memberExpression) {
                $this->propertyComponentIdMap[$memberExpression] = $componentId;
            }
        );
    }
748433
public function updateColumn($columnId, $key, $value)
    {
        if (isset($this->_columns[$columnId]) && $this->_columns[$columnId] instanceof Varien_Object) {
            $this->_columns[$columnId]->setData($key, $value);
        }

        return $this;
    }
785336
protected function _addRelationFieldInLocalModel() {
        if (!$this->isSingular()) {
            return;
        }

        $column = Garp_Spawn_Relation_Set::getRelationColumn($this->name);
        $fieldParams = array(
            'model' => $this->model,
            'type' => 'numeric',
            'editable' => true,
            'visible' => true,
            'primary' => $this->primary,
            'required' => $this->required,
            'relationAlias' => $this->name,
            'relationType' => $this->type
        );
        if ($this->multilingual && $this->_localModel->isMultilingual()) {
            // The relation is added to the i18n model by Garp_Spawn_Config_Model_I18n
            return;
        }
        $this->_localModel->fields->add('relation', $column, $fieldParams);
    }
485501
public function addReference($ruleKey, $columns, $refTableClass, $refColumns,
                                 $onDelete = null, $onUpdate = null)
    {
        $reference = array(self::COLUMNS         => (array) $columns,
                           self::REF_TABLE_CLASS => $refTableClass,
                           self::REF_COLUMNS     => (array) $refColumns);

        if (!empty($onDelete)) {
            $reference[self::ON_DELETE] = $onDelete;
        }

        if (!empty($onUpdate)) {
            $reference[self::ON_UPDATE] = $onUpdate;
        }

        $this->_referenceMap[$ruleKey] = $reference;

        return $this;
    }
1337819
public function foreignMany($related, $foreignKey = null, $localKey = null)
    {
        $instance = new $related;

        $foreignKey = $foreignKey ?: Str::snake(class_basename($this)).'_id';

        $localKey = $localKey ?: '_id';

        return new ForeignMany($this, $instance->query(['*']), $foreignKey, $localKey);
    }
1339308
public function addOneToMany($schema, $foreign_id = null, $col = null, $name = null, $one = null)
  {
    $m = $this->getManager();
    $s = $schema instanceof Schema ? $schema : $m->getSchema($schema, true);
    $n = $name ?: $s->getName();

    $this->relations[$n] = array(
      'type'       => static::RELATION_ONE_TO_MANY,
      'column'     => $col ?: $this->getPrimaryKey(),
      'schema'     => $s,
      'foreign_id' => $foreign_id ?: StaticStringy::underscored($this->getItemClass(false) . '_id'),
      'name'       => $n,
      'one'        => $one ?: $s->getItemClass(false),
    );

    return $this;
  }
1096589
public function getLocalizedColumn($key, $locale = 'en')
    {
        if (empty($locale)) {
            $locale = 'en';
        }
        $localizedKey = $key.'_'.strtolower($locale);
        $value        = $this->$localizedKey;
        if (empty($value)) {
            $localizedKey = $key.'_en';
            $value        = $this->$localizedKey;
        }

        return $value;
    }
1070852
final protected function setForeignKey(array $rows, string $foreignKey, $value)
    {
        foreach ($rows as $row) {
            $row->setColumn($foreignKey, $value);
        }
    }
1352338
protected function addAllClassFields($class, $alias, $columnAliasMap = array())
    {
        $classMetadata = $this->em->getClassMetadata($class);
        $platform      = $this->em->getConnection()->getDatabasePlatform();

        if ( ! $this->isInheritanceSupported($classMetadata)) {
            throw new \InvalidArgumentException('ResultSetMapping builder does not currently support your inheritance scheme.');
        }


        foreach ($classMetadata->getColumnNames() as $columnName) {
            $propertyName = $classMetadata->getFieldName($columnName);
            $columnAlias  = $platform->getSQLResultCasing($columnAliasMap[$columnName]);

            if (isset($this->fieldMappings[$columnAlias])) {
                throw new \InvalidArgumentException("The column '$columnName' conflicts with another column in the mapper.");
            }

            $this->addFieldResult($alias, $columnAlias, $propertyName);
        }

        foreach ($classMetadata->associationMappings as $associationMapping) {
            if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
                foreach ($associationMapping['joinColumns'] as $joinColumn) {
                    $columnName  = $joinColumn['name'];
                    $columnAlias = $platform->getSQLResultCasing($columnAliasMap[$columnName]);

                    if (isset($this->metaMappings[$columnAlias])) {
                        throw new \InvalidArgumentException("The column '$columnAlias' conflicts with another column in the mapper.");
                    }

                    $this->addMetaResult(
                        $alias,
                        $columnAlias,
                        $columnName,
                        (isset($associationMapping['id']) && $associationMapping['id'] === true)
                    );
                }
            }
        }
    }
1194526
protected function _relationship($modelName, $relationship, $foreignKey=null, $localKey=null)
    {
        /**
         * PSR-4 support check
         * 
         * @see https://github.com/yidas/codeigniter-psr4-autoload
         */
        if (strpos($modelName, "\\") !== false ) {
            
            $model = new $modelName;

        } else {
            // Original CodeIgniter 3 model loader
            get_instance()->load->model($modelName);
            $model = $this->$modelName;
        }

        $libClass = __CLASS__;
        
        // Check if is using same library
        if (!is_subclass_of($model, $libClass)) {
            throw new Exception("Model `{$modelName}` does not extend {$libClass}", 500);
        }

        // Keys
        $foreignKey = ($foreignKey) ? $foreignKey : $this->primaryKey;
        $localKey = ($localKey) ? $localKey : $this->primaryKey; 

        $query = $model->find()
            ->where($foreignKey, $this->$localKey);

        // Inject Model name into query builder for ORM relationships
        $query->modelName = $modelName;
        // Inject relationship type into query builder for ORM relationships
        $query->relationship = $relationship;

        return $query;
    }
228763
public function foreignKey(string $foreignKeyName): ForeignKeyLocalColumnsDefiner
    {
        return new ForeignKeyLocalColumnsDefiner(function (
            array $localColumnNames,
            $referencedTable,
            array $referencedColumns,
            $onUpdateMode,
            $onDeleteMode
        ) use ($foreignKeyName) {
            $this->foreignKeys[] = new ForeignKey(
                $this->orm->getNamespace() . $foreignKeyName,
                $localColumnNames,
                $referencedTable,
                $referencedColumns,
                $onUpdateMode,
                $onDeleteMode
            );
        });
    }