Compile Exists Rule

[exists:table,column] Check that the contents of a table field exist

@param string $key
@param string $masque

@return void
179971
protected function compileExists($key, $masque)
    {
        if (!preg_match("/^exists:(.+)$/", $masque, $match)) {
            return;
        }

        $catch = end($match);
        $parts = explode(',', $catch);

        if (count($parts) == 1) {
            $exists = Database::table($parts[0])
                ->where($key, $this->inputs[$key])->exists();
        } else {
            $exists = Database::table($parts[0])
                ->where($parts[1], $this->inputs[$key])->exists();
        }

        if (!$exists) {
            $this->last_message = $this->lexique('exists', $key);
            
            $this->fails = true;
            
            $this->errors[$key][] = [
                "masque" => $masque,
                "message" => $this->last_message
            ];
        }
    }
327786
protected function compileAlpha($key, $masque)
    {
        if (!preg_match("/^alpha$/", $masque)) {
            return;
        }

        if (Str::isAlpha($this->inputs[$key])) {
            return;
        }

        $this->last_message = $this->lexique('alpha', $key);
        
        $this->fails = true;
        
        $this->errors[$key][] = [
            "masque" => $masque,
            "message" => $this->last_message
        ];
    }
1117140
function offsetexists($key) {
		return Base::instance()->visible($this,$key)?
			isset($this->$key):
			($this->exists($key) && $this->get($key)!==NULL);
	}
860918
protected function runTableExists($key, $datas, $rule)
    {
        $data = $datas[$key];

        $advanced = Database::table($data)->tableExists();

        if (!$advanced->isSuccess()) {
            $this->fails[] = $messageKey = "$rule.$key";

            $this->addMessage($key, $rule, $messageKey);
        }
    }
1313046
public function exists($key)
    {
        if ($this->isMappedKey($key)) {
            return false;
        } else {
            return $this->getDriver()->exists($key);
        }
    }
1272101
public function exists( $key ) {
		return ( is_array( $this->data ) && array_key_exists( $key, $this->data ) ) ||
			( is_object( $this->data ) && property_exists( $this->data, $key ) );
	}
861895
protected function compileInt($key, $masque)
    {
        if (!preg_match("/^int$/", $masque, $match)) {
            return;
        }

        if (is_int($this->inputs[$key])) {
            return;
        }

        $this->last_message = $this->lexique('int', $key);
        
        $this->fails = true;
        
        $this->errors[$key][] = [
            "masque" => $masque,
            "message" => $this->last_message
        ];
    }
669642
public function exists(string $key): bool
    {
        $key = $this->getKey($key);

        return cache()->has($key);
    }
589479
final public static function exists($keys): bool {
		
		// initialize some vars
		$db			= Database::getInstance();
		$tableKey	= (array)static::TABLE_KEY;
		$conds		= array();

		foreach ($tableKey as $field) {
			$conds[] = $field . ' = ?';
		}
		
		$query = 'SELECT COUNT(1) FROM `' . static::TABLE_NAME . '` WHERE ' . implode(' AND ', $conds);
		
		// execute and return value
		return (bool)Database::load($query, (array)$keys, PAIR_DB_COUNT);
		
	}
949525
public function exists($table, $column = null)
    {
        $rule = $table;

        // Take any argument after the 2 defined ones
        $args = array_slice(func_get_args(), 2);

        if (isset($column)) {
            $rule .= ",$column";
        }

        if ($args) {
            // Add optional arguments
            foreach ($args as $arg) {
                $rule .= ",$arg";
            }
        }

        $this->addRule("exists:$rule");
        return $this;
    }
46211
public function tableHaskey($table, $key)
	{
		$keys = $this->getTableKeys($table);

		if (!is_array($keys))
		{
			return false;
		}

		return isset($keys[$key]);
	}
1296988
function has($key)
    {
        \Poirot\Storage\assertKey($key);


        $realm = $this->getRealm();

        try {

            $sql = "SELECT COUNT(*) as has_key FROM `KVStore` WHERE `realm` = '$realm' and `key` = '$key';";
            $stm = $this->pdo->prepare($sql);
            $stm->execute();
            $stm->setFetchMode(\PDO::FETCH_ASSOC);

            $count = $stm->fetch();
            $count = (int) $count['has_key'];

        } catch (\Exception $e) {
            throw new exReadError($e->getMessage(), $e->getCode(), $e);
        }

        return ($count > 0);
    }
1342920
public function exists($key)
    {
        $this->setScope($key);
        $result = is_array($this->scope) ? parent::exists($key) : false;
        /** @noinspection PhpInternalEntityUsedInspection */
        $this->key = null;

        return $result;
    }
278793
public function has($key)
	{
		$key = $this->id($key);
		return $this->apcu ? apcu_exists($key) : apc_exists($key);
	}
878539
protected function compileAlphaNum($key, $masque)
    {
        if (!preg_match("/^alphanum$/", $masque)) {
            return;
        }

        if (Str::isAlphaNum($this->inputs[$key])) {
            return;
        }

        $this->last_message = $this->lexique('alphanum', $key);
        
        $this->fails = true;
        
        $this->errors[$key][] = [
            "masque" => $masque,
            "message" => $this->last_message
        ];
    }
930580
public function exists($commandKey, $cacheKey)
    {
        return array_key_exists($commandKey, $this->cachedResults)
            && array_key_exists($cacheKey, $this->cachedResults[$commandKey]);
    }
888325
function exists($key) {
		$key=$this->fixheader($key);
		return isset($this->headers[$key]);
	}