Check if parametrized field exists in api model
@param TableMap $tableMap
@param $field
@return \Propel\Runtime\Map\ColumnMap|null
543588
public static function checkFieldExists(TableMap $tableMap, $field)
    {
        $column = null;
        try {
            foreach($tableMap->getColumns() as $tableMapColumn) {
                $columnName = $tableMapColumn->getPhpName();
                if(preg_match('/^'.$field.'$/i', $columnName)) {
                    $column = $tableMapColumn;
                    break;
                }
            }
        } catch (\Exception $e) {
            Logger::log($e->getMessage(), LOG_DEBUG);
        }
        return $column;
    }
315661
public final function orField($fieldName, $tableName = null)
    {
        return new QueryHelper\QueryField($this, $this->_prepareField($fieldName, $tableName), 'OR');
    }
507399
public function findWhereNotIn($field, array $values, $columns = ['*'])
    {
        return parent::findWhereNotIn(
            $this->getColumnName($field),
            $values,
            $this->getColumnsNames($columns)
        );
    }
886345
protected function _field($field) {
		if (!isset($this->_config['fieldMap'][$field])) {
			throw new RuntimeException(__d('user_tools', 'Invalid field "%s"!', $field));
		}

		return $this->_config['fieldMap'][$field];
	}
1354643
private function convertColumnAnnotationToFieldMetadata(string $tableName, Column $column, string $fieldName)
    {
        $options       = [];
        $fieldMetadata = new Mapping\FieldMetadata($fieldName);

        $fieldMetadata->setType($column->getType());
        $fieldMetadata->setTableName($tableName);
        $fieldMetadata->setColumnName($column->getName());

        // Type specific elements
        switch ($column->getType()->getName()) {
            case Type::TARRAY:
            case Type::BLOB:
            case Type::GUID:
            case Type::JSON_ARRAY:
            case Type::OBJECT:
            case Type::SIMPLE_ARRAY:
            case Type::STRING:
            case Type::TEXT:
                if ($column->getLength()) {
                    $fieldMetadata->setLength($column->getLength());
                }

                $options['fixed'] = $column->getFixed();
                break;

            case Type::DECIMAL:
            case Type::FLOAT:
                $fieldMetadata->setScale($column->getScale());
                $fieldMetadata->setPrecision($column->getPrecision());
                break;

            case Type::INTEGER:
            case Type::BIGINT:
            case Type::SMALLINT:
                $options['unsigned'] = $column->getUnsigned();
                break;
        }

        // Comment
        $comment = $column->getComment();
        if ($comment !== null) {
            $options['comment'] = $comment;
        }

        // Default
        $default = $column->getDefault();
        if ($default !== null) {
            $options['default'] = $default;
        }

        $fieldMetadata->setOptions($options);

        return $fieldMetadata;
    }
891848
public static function dbField($table, $field, $where) {

        $fldValue = "";
        $row = self::dbRow($table, ['type'=>'num', 'fl'=>$field, 'where'=>$where]);
        if (!empty($row)) {
            list($fldValue) = $row;
        }
        return $fldValue;
    }
190378
public static function field_exists($table, $columns, $db = null)
	{
		if ( ! is_array($columns))
		{
			$columns = array($columns);
		}

		try
		{
			\DB::select_array($columns)->from($table)->limit(1)->execute($db ? $db : static::$connection);
			return true;
		}
		catch (\Database_Exception $e)
		{
			// check if we have a DB connection at all
			$connection = \Database_Connection::instance($db ? $db : static::$connection)->has_connection();

			// if no connection could be made, re throw the exception
			if ( ! $connection)
			{
				throw $e;
			}

			return false;
		}
	}
921461
public function mapColumn($field, callable $callback)
    {
        return $this->map(
            function (Data $data) use ($field, $callback) {
                $data->$field = $callback($data->$field);

                return $data;
            }
        );
    }
111826
public function select($table = null, $fields = null)
    {
        return $this->table($table)->select($fields);
    }
1199930
protected function checkFieldExists($table, $field)
	{
		$this->connect();

		$table = $this->replacePrefix((string) $table);
		$this->setQuery(
			"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$table' AND COLUMN_NAME = '$field' ORDER BY ORDINAL_POSITION"
		);

		if ($this->loadResult())
		{
			return true;
		}

		return false;
	}
157667
public static function require_field($table, $field, $spec)
    {
        self::get_schema()->requireField($table, $field, $spec);
    }
496795
public function getMigrationClassPathByKey($table, $field = null)
    {
        $name = is_null($field) ?
            $this->getTableMigrationName($table) :
            $this->getTableFieldMigrationName($field, $table);

        return $this->getMigrationClassPath($name);
    }
656313
protected function _findRelatedRecord(Table $table, string $field, string $value) : string
    {
        $csvField = FieldUtility::getCsvField($table, $field);
        if (null !== $csvField && 'related' === $csvField->getType()) {
            $relatedTable = (string)$csvField->getLimit();
            $value = $this->_findRelatedRecord(
                TableRegistry::get($relatedTable),
                TableRegistry::get($relatedTable)->getDisplayField(),
                $value
            );
        }

        foreach ($table->associations() as $association) {
            if ($association->getForeignKey() !== $field) {
                continue;
            }

            $targetTable = $association->getTarget();

            $primaryKey = $targetTable->getPrimaryKey();
            if (! is_string($primaryKey)) {
                throw new UnsupportedPrimaryKeyException();
            }

            // combine lookup fields with primary key and display field
            $lookupFields = array_merge(
                FieldUtility::getLookup($targetTable),
                [$primaryKey, $targetTable->getDisplayField()]
            );

            // remove virtual/non-existing fields
            $lookupFields = array_intersect($lookupFields, $targetTable->getSchema()->columns());

            // alias lookup fields
            foreach ($lookupFields as $k => $v) {
                $lookupFields[$k] = $targetTable->aliasField($v);
            }

            // populate lookup field values
            $lookupValues = array_fill(0, count($lookupFields), $value);

            $query = $targetTable->find('all')
                ->enableHydration(true)
                ->select([$targetTable->aliasField($primaryKey)])
                ->where(['OR' => array_combine($lookupFields, $lookupValues)]);

            try {
                $entity = $query->firstOrFail();
            } catch (RecordNotFoundException $e) {
                continue;
            }

            Assert::isInstanceOf($entity, EntityInterface::class);

            return $entity->get($primaryKey);
        }

        return $value;
    }
918696
public static function create_field($table, $field, $spec)
    {
        return self::get_schema()->createField($table, $field, $spec);
    }
538381
public function isFieldExists($table, $field)
	{
		if (isset($this->tables[$table])) {
			$fields = $this->getFields($table);

			return $fields->where('name', $field)->count() > 0;
		}

		return false;
	}
540510
public static function getField($field)
    {
        return isset(self::$fields[$field]) ? self::$fields[$field] : null;
    }
688526
public static function getCsvField(RepositoryInterface $table, string $field) : ?CsvField
    {
        if ('' === $field) {
            return null;
        }

        $moduleName = App::shortName(get_class($table), 'Model/Table', 'Table');

        $config = new ModuleConfig(ConfigType::MIGRATION(), $moduleName);
        $parsed = $config->parse();

        if (! property_exists($parsed, $field)) {
            return null;
        }

        $parsed = json_encode($parsed->{$field});
        if (false === $parsed) {
            return null;
        }

        return new CsvField(json_decode($parsed, true));
    }