Sets lookup conditions for entity table search

@param type $key
@param type $value
@param type $type
@param type $exact
@param type $escape
@return \Platform\Entity
328465
final public function setListLookUpConditions($key, $value = NULL, $type = 'AND', $exact = FALSE, $escape = TRUE, $comparison = "LIKE")
    {

        if (empty($key)) {
            return $this;
        }
        if (!is_array($key)) {
            if (is_null($value)) { //some values could be '' so don't use empty here
                return $this;
            }
            $key = array($key => $value);
        }
        //print_R($key);
        $dataModel = $this->getPropertyModel();
        foreach ($key as $k => $v) {

            //For count queries, we will only add properties if their value is in having or where clause;
            if (array_key_exists($k, $dataModel)):
                $this->listLookUpConditionProperties[] = $k;
            endif;

            //The firs item adds the and prefix;
            $prefix = (count($this->listLookUpConditions) == 0 AND count($this->listLookUpConditions) == 0) ? '' : $type . "\t";
            if ($escape === TRUE) {
                $v = $this->database->escape($v);
                //$v = $this->quote( stripslashes($v) );
            }
            if (empty($v)) {
                // value appears not to have been set, assign the test to IS NULL 
                // IFNULL(xxx, '')
                $v = " IS NULL";
            } else {
                if (is_array($v)):
                    $_values = array_map(array($this->database, "quote"), $v);
                    $values = implode(',', $_values);
                    $v = " IN ($values)";
                else:
                    $v = (strtoupper($comparison) == "LIKE") ? " LIKE '%{$v}%'" : " {$comparison} '{$v}'";
                endif;
            }
            if ($exact && is_array($this->listLookUpConditions) && !empty($this->listLookUpConditions)):
                $conditions = implode("\t", $this->listLookUpConditions);
                $this->listLookUpConditions = array();
                $this->listLookUpConditions[] = "(" . $conditions . ")";
            endif;
            $this->listLookUpConditions[] = $prefix . $k . $v;
        }

        return $this;
    }
463506
public function find( $key, $value ) {
		global $wpdb;
		$query   = <<< SQL
			SELECT * FROM {$wpdb->usermeta}
			WHERE meta_key LIKE %s
			AND   meta_value LIKE %s
SQL;
		$results = $wpdb->get_results( $wpdb->prepare( $query, $this->get_meta_key( $key ), $value ) );

		return $this->apply_filters( 'find_user_meta', $this->app->utility->array_pluck( $results, 'user_id' ), $key, $value );
	}
1172913
public function pref($key, $value = null, $type = 'string')
    {
        if (isset($value)) {
            $this->preferences()->updateOrCreate(['key' => $key], ['value' => $this->cast($value, $type),
                                                                   'type'  => $type, ]);

            Cache::put("{$this->slug}.'/'.{$key}", $value, 60);
            return $value;
        }

        if($value = Cache::get("{$this->slug}.'/'.{$key}"))
        {
            return $value;
        }

        if ($pref = $this->preferences()->forKey($key)->first()) {
            $value = $pref->value();
            $type = $pref->type();
        } else {
            $default = Preference::getDefault($this, $key);
            $value = $default->value();
            $type = $default->type();
        }
        
        Cache::put("{$this->slug}.'/'.{$key}", $value, 60);
        return $this->cast($value, $type);
    }
422274
public function where($condition, $value = null, $type = null)
    {

        switch ($type) {
            case null:
                $clause = 'WHERE';
                break;
            case 'or':
                $clause = 'OR';
                break;
            case 'and':
                $clause = 'AND';
                break;
            default:
                $clause = 'WHERE';
        }

        $this->oosql_where .= " $clause $condition";

        if ($value instanceof oosql) {

            $this->oosql_where .= $value->getSql();
        } elseif (null !== $value) {

            $this->oosql_conValues[] = $value;
        }

        return $this;
    }
1373323
public function set($key, $value) {
        if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key));
        $this->setProperty($key, $value);
        return $this;
    }
1127623
public function whereKey($value)
    {
        $repo = $this->getRepo();

        $this->select->where("{$repo->getTable()}.{$repo->getPrimaryKey()}", $value);

        return $this;
    }
1152634
public function bind($key, $value, $type = self::TYPE_DEFAULT)
    {
        // Check if locked
        if (isset($this->locked[$key])) {
            throw new \RuntimeException('Cannot override locked content "'. $key .'".');
        }

        // Check if value should be validated
        if (isset($this->validators[$key])) {
            $value = $this->validators[$key]->validate($value);
        }

        // Save key, type and value
        $this->keys[$key] = true;
        $this->types[$key] = $type;
        $this->raw[$key] = $value;
    }
930590
public function getOrSet($key, $value, $section = null, $type = null)
    {
        if ($this->has($key, $section, true)) {
            return $this->get($key, $section);
        } else {
            return $this->set($key, $value, $section, $type);
        }
    }
1226835
public static function transferParameter($key, $value, $type): array
    {
        if (!\is_int($key) && !\is_string($key)) {
            throw new DbException('Key must to be int Or string! ');
        }
        $key = self::formatParamsKey($key);

        // 参数值类型转换
        if ($type !== null) {
            $value = self::trasferTypes($type, $value);
        }

        return [$key, $value];
    }
673222
public function equalTo($key, $value)
    {
        if ($value === null)
        {
            $this->doesNotExist($key);
        } else
        {
            $this->where[$key] = $value;
        }

        return $this;
    }
391886
public function search( $value, $alwaysOutputAsArray = false )
    {

        if( $value instanceof Container ) {

            $output = array();
            foreach( array_keys( $value->collection ) as $key ) {
                $output[$key] = isset( $this->collection[$key] ) ? $key : false;
            }
            return $output;

        } elseif ( is_object($value) ) {

            $hash = spl_object_hash( $value );
            $search = isset( $this->collection[$hash] ) ? $hash : false;
//            $search = \array_search( $value, $this->collection, true );
            return $alwaysOutputAsArray ? array( $search ) : $search ;

        } elseif( is_array( $value ) ) {

            $output = array();
            foreach( $value as $key => $entity ) {
                $output[$key] = $this->search( $entity );
            }
            return $output;

        }

        return $alwaysOutputAsArray ? array( false ) : false ;

    }
29748
public function scopeHasAttribute(Builder $query, string $key, $value): Builder
    {
        return $query->whereHas($key, function (Builder $query) use ($value) {
            $query->where('content', $value)->where('entity_type', get_class($this));
        });
    }
371434
public function escape($value, $type){
		switch($type){
			case Manager::BOOL:
				return $value ? 'TRUE' : 'FALSE';

			case Manager::TEXT:
				return "'" . pg_escape_string($this->resource, $value) . "'";

			case Manager::BINARY:
				return "'" . pg_escape_bytea($this->resource, $value) . "'";

			case Manager::IDENTIFIER:
				return '"' . str_replace('.', '"."', str_replace('"', '""', $value)) . '"';

			case Manager::DATETIME:
				return ($value instanceof DateTime) ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);

			default:
				throw new InvalidArgumentException('Unsupported data type.');
				break;
		}
	}
445744
public function findOneBy($column, $value, $returnType = Table::RETURN_MODEL) {
        return $this->findOneWhere(array(array($column => $value)), $returnType);
    }
1017575
public function set($type = null, $key = null, $value = null)
    {
        if (isset($type)) {
            $this->request[$type]["$key"] = $value;
        } else {
            $this->request = array(
                'get' => $_GET,
                'post' => $_POST,
                'files' => $_FILES,
                'cookie' => $_COOKIE
            );
        }

        return $this;
    }
1131514
public function addType(Search $entity)
    {
        if ($entity->getType() instanceof Type) {
            $this->add(function (QueryBuilder $query) use ($entity) {
                $query
                    ->andWhere('i.type = :type')
                    ->setParameter('type', $entity->getType()->getId());
            });
        }

        return $this;
    }
886702
private static function from($type, $key, $default, &$source = null) {

    	if(null === $source) {

	    	if(static :: isMethod($type)) {

	    		$source = [];
	    		static :: parseRawHttpRequest($source);
	    	}
    	}

    	static :: $method = ['method' => $type, 'data' => &$source];

    	if(null !== $key) {
    		return static :: get($key, $default);
    	}

    	return $source;
    }