Checks if a map exists

@param array $map
@param string $modelName
@param string $tableName

@return bool
14147
protected function mapExists(array $map, $modelName, $tableName = null)
    {
        // First we try to find an entry by model-name
        // if not found, we try to find one using the table-name if a value is provided
        $found = isset($map['model-name']) && $map['model-name'] == $modelName;

        if (!$found && !empty($tableName)) {
            $found = isset($map['table-name']) && $map['table-name'] == $tableName;
        }

        return $found;
    }
454016
public function hasKey($key)
    {
        if (array_key_exists($key, $this->data)) {
            return true;
        }

        $entity = $this->getEntity();
        if ($entity->getRepository()->getCache()->tableHasField($entity->getTable(), $key)) {
            return true;
        }

        if ($entity->getRepository()->getCache()->tableHasField($entity->getTable() . '_i18n', $key)) {
            return true;
        }

        return false;
    }
1114259
protected function getMappedKey($map, $key)
    {
        if (is_array($map)) {
            if (array_key_exists($key, $map)) {
                return $map[$key];
            } else {
                return $key;
            }
        }
        return $key;
    }
29610
public function xor(Map $map): Map
    {
        return $this->merge($map)->filter(function($key) use ($map) {
            return $this->hasKey($key) ^ $map->hasKey($key);
        });
    }
884918
protected function tableExists($tableName)
    {
        $rs = $this->getEntityManager()->getConnection()->fetchAll('SHOW TABLE STATUS');

        foreach ($rs as $row) {
            if ($tableName === $row['Name']) {
                return true;
            }
        }

        return false;
    }
596801
public function extend_fieldmap($map)
    {
        if (is_array($map)) {
            self::$fieldmap = array_merge($map, self::$fieldmap);
        }
    }
639670
public function exists($model, $query)
    {
        //
        $params = [];

        //
        $whereArray = [];

        //
        if (isset($query['where'])) {
            $whereArray[] = $query['where'];
            unset($query['where']);
        }

        //
        $schema = $this->getFields($model);

        foreach ($schema as $field) {
            if (!isset($query[$field])) {
                continue;
            }
            $value = $query[$field];
            $token = ':'.$field;
            $params[$token] = $value;
            $whereArray[] = "`{$field}` = {$token}";
        }

        $where = count($whereArray) > 0
               ? 'WHERE '.implode(' AND ', $whereArray) : '';

        $table = $this->getPrefix($model);
        $sql = "SELECT * FROM `{$table}` {$where} LIMIT 1";
        $row = $this->getRow($sql, $params);

        return $row;
    }
618677
public static function getModelTable($tableName) {
        $mt = DATA . 'mapper' . DIRECTORY_SEPARATOR . '__modelTables.php';
        if (!is_readable($mt))
            return array();

        $modelTables = include $mt;
        if (isset($modelTables[$tableName]))
            return $modelTables[$tableName];

        return array();
    }
726975
public function update($table, array $map = []): Query\UpdateQuery
    {
        $query = $this->engine->makeUpdate()->table($table);
        if (empty($map) === false) {
            $query = $query->set($map);
        }
        return $query;
    }
867251
public static function hasTable($tableName)
    {
        // Cache the list of all table names to reduce on DB traffic
        if (empty(self::$_cache_all_tables) && DB::is_active()) {
            self::$_cache_all_tables = DB::get_schema()->tableList();
        }
        return !empty(self::$_cache_all_tables[strtolower($tableName)]);
    }
228780
public function mapParams(array $map, $params = null)
    {
        if (!isset($params)) {
            $params = $this->params;
        }

        $mapped = array();

        foreach ($params as $key => $value) {
            if (isset($map[$key]) && is_string($map[$key])) {
                gplcart_array_set($mapped, $map[$key], $value);
            }
        }

        return $mapped;
    }
776195
public static function mapsWith(array $map)
    {
        return self::tuples($map)->fmap(function ($vals) use ($map) {
            return array_combine(array_keys($map), $vals);
        });
    }
901754
public function hasOne($modelName, $foreignKey=null, $localKey=null)
    {
        return $this->_relationship($modelName, __FUNCTION__, $foreignKey, $localKey);
    }
574904
public function addTable($tableName)
    {
        $this->tables[$tableName] = new TableMap($tableName, $this);

        return $this->tables[$tableName];
    }
621608
public function tableExists($name)
    {
        $tables = $this->listTables();
        foreach ($tables as $tableName) {
            if ($tableName == $name) {
                return true;
            }
        }

        return false;
    }
784144
public static function isMap($val): bool
    {
        if (!\is_array($val)) {
            return false;
        }

        /** @var array $val */
        $keys = \array_keys($val);

        return \array_keys($keys) !== $keys;
    }
451795
public function checkTableExists(string $tableName): bool
    {
        try {
            $result = $this->pdo->query("SELECT 1 FROM $tableName LIMIT 1");
        } catch (\Exception $e) {
            return false;
        }

        return $result !== false;
    }