Generate a pseudo select to log

@param object $model Model
@param array $queryData Query data sended by find
@return string Pseudo query
424805
protected function _pseudoSelect(Model $model, &$queryData) {
		$out = '(symbolic) SELECT ';
		if (empty($queryData['fields'])) {
			$out .= '*';
		} elseif ($queryData['fields']) {
			$out .= 'COUNT(*)';
		} else {
			$out .= implode(', ', $queryData['fields']);
		}
		$out .= ' FROM ' . $model->alias;
		if (!empty($queryData['conditions'])) {
			$out .= ' WHERE';
			foreach ($queryData['conditions'] as $id => $condition) {
				if (empty($condition)) {
					continue;
				}
				if (is_array($condition)) {
					$condition = '(' . implode(', ', $condition) . ')';
					if (strpos($id, ' ') === false) {
						$id .= ' IN';
					}
				}
				if (is_string($id)) {
					if (strpos($id, ' ') !== false) {
						$condition = $id . ' ' . $condition;
					} else {
						$condition = $id . ' = ' . $condition;
					}
				}
				if (preg_match('/^(\w+\.)?\w+ /', $condition, $matches)) {
					if (!empty($matches[1]) && substr($matches[1], 0, -1) !== $model->alias) {
						continue;
					}
				}
				$out .= ' (' . $condition . ') &&';
			}
			$out = substr($out, 0, -3);
		}
		if (!empty($queryData['order'][0])) {
			$out .= ' ORDER BY ' . implode(', ', $queryData['order']);
		}
		if (!empty($queryData['limit'])) {
			$out .= ' LIMIT ' . (($queryData['page'] - 1) * $queryData['limit']) . ', ' . $queryData['limit'];
		}
		return $out;
	}
1040714
public function getQueryStr($queryData = null) {
		$query = (string)$queryData;
		if (!empty($query)) {
			$query = trim($query);
		}

		return $query;
	}
1203724
protected function createFindQuery(): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->select('id', 'locale', 'name', 'disabled')
            ->from('ezcontent_language');

        return $query;
    }
1318050
protected function _registerLog(Model $model, &$queryData, $took, $numRows) {
		if (!Configure::read()) {
			return;
		}
		$this->_requestsLog[] = array(
			'query' => $this->_pseudoSelect($model, $queryData),
			'error' => '',
			'affected' => 0,
			'numRows' => $numRows,
			'took' => round($took, 3)
		);
	}
403264
public function select( $request, $query_params = [] )
	{
		if( is_array($request) )
		{
			$template = reset($request);
			$query_params = end($request);
		}
		else if( is_string($request) )
		{
			$template = $request;
		}

		$statement = $this->_query_( $template, $query_params );

		$results = [];
		try {
			$results = $statement->fetchAll( \PDO::FETCH_ASSOC );
		} catch (PDOException $e) {
			if( DB_DEBUG_QUERY )
			{
				debug($e->getMessage());
			} 
			else
			{
				debug('Query Error');
			}
			exit;
		}

		return $results;
	}
170195
public function sumDuplicateQueries($modelData)
    {
        $numDuplicates = 0;
        $duplicates = ArrayHelper::getColumn($modelData, 'duplicate');
        foreach ($duplicates as $duplicate) {
            if ($duplicate > 1) {
                $numDuplicates++;
            }
        }

        return $numDuplicates;
    }
1077456
public static function query($alias = null, $model = null)
    {
        if (!$model) {
            $model = Di::getDefault()->getShared(static::class);
        }

        $query = $model->_di->get('ManaPHP\Db\Query')->setModel($model);
        if ($alias) {
            $query->from(get_class($model), $alias);
        }

        return $query;
    }
1138914
public function selectOne($query, $bindings = [])
    {
        $start = $this->getLogTime();

        try {

            $result = $this->wpdb->get_row($this->bindParams($query, $bindings));

            if ($result === false || $this->wpdb->last_error) {
                throw new QueryException($query, $bindings, new \Exception($this->wpdb->last_error));
            }

            return $result;

        } catch (QueryException $e) {
            throw $e;
        } finally {
            $this->logQuery($query, $bindings, $this->getElapsedTime($start));
        }
    }
1332208
public function findBy(AbstractModel $model, $param = [])
    {
        if ($this->useCache && $this->modelCache) {
            if (($ret = $this->modelCache->get($model, $param))) {
                return $ret;
            }
        }

        list($query, $param, $type) = $this->queryBuilder->generateSelectForModel($model, $param);

        $result = $this->executeQuery(
            $model,
            $this->prepare(
                $query,
                $this->prepareParam($param)
            )
        );

        if ($this->useCache && $this->modelCache) {
            $this->modelCache->set($model, $param);
        }

        return $result;
    }
256793
private function getAction(Model $Model)
	{
		$isCreate = true;
		$id = null;

		if (isset($Model->data[$Model->alias][$Model->primaryKey]) && !empty($Model->data[$Model->alias][$Model->primaryKey])) {
			$id = $Model->data[$Model->alias][$Model->primaryKey];
		}
		elseif (!empty($Model->id)) {
			$id = $Model->id;
		}

		if (!empty($id)) {
			$isCreate = !$Model->exists($id);
		}

		return $isCreate ? 'create' : 'modify';
	}
228500
protected function search(ModelCriteria $query, Request $request)
    {
        $filters = $this->getFilters($request);

        if (empty($filters)) {
            return $query;
        }

        $conditions = array();

        $columns = $this->getSearchColumns($request);

        if (is_array($filters)) {
            foreach ($columns as $name => $condition) {
                $items = explode('.', $name);
                $i = 0;
                $values = $filters;

                while (is_array($values) && array_key_exists($items[$i], $values)) {
                    $values = $values[$items[$i]];
                    $i++;
                }

                if (is_array($values)) {
                    continue;
                } else {
                    $value = trim($values);
                }

                if (empty($value) && !is_numeric($value)) {
                    continue;
                }

                $query->condition(
                    'search_'.$name,
                    sprintf($condition, $value)
                );

                $conditions[] = 'search_'.$name;
            }

            if (!empty($conditions)) {
                return $query->where($conditions, 'and');
            }
        } else {
            $value = trim($filters);

            foreach ($columns as $name => $condition) {
                $query->condition(
                    'search_'.$name,
                    sprintf($condition, $value)
                );

                $conditions[] = 'search_'.$name;
            }

            if (!empty($conditions)) {
                return $query->where($conditions, 'or');
            }
        }
    }
1074390
public function executeGetColumnData($model, $params = [])
	{
		$value = null;
		if (isset($params['value']) && $params['value'] !== null) {
			if (is_string($params['value'])) {
				$value = ArrayHelper::getValue($model, $params['value']);
			} else {
				$value = call_user_func($params['value'], $model, $this);
			}
		} elseif (isset($params['attribute']) && $params['attribute'] !== null) {
			$value = ArrayHelper::getValue($model, $params['attribute']);
		}

		if (isset($params['format']) && $params['format'] != null)
			$value = $this->formatter()->format($value, $params['format']);

		return $value;
	}
524700
private function modelVision(Model $model, $where, $value, $name, $querymap = null) : Model
  {
    if (strpos($where, '__') !== false) {
      $querymap = explode('__', $where)[1];
      $field = explode('__', $where)[0];
    }

    if (isset(HttpFoundation::$routeModelBinding['model'][$querymap])) {
      return (new HttpFoundation::$routeModelBinding['model'][$querymap])->persist($model, $field, $value, $name);
    }

    return $model->where($where, $value)->first() ?? $model;
  }
496637
protected function generateQueryClassName($modelClassName)
    {
        $queryClassName = $this->queryClass;
        if (empty($queryClassName) || strpos($this->tableName, '*') !== false) {
            $queryClassName = $modelClassName . 'Query';
        }
        return $queryClassName;
    }
1353239
private static function buildQuery($queryArray)
    {
        $query = '';
        foreach ($queryArray as $key => $pieceOfQuery) {
            $pieceOfQuery = implode(',', $pieceOfQuery);
            $query .= $key . '=' . $pieceOfQuery . '&';
        }

        $query = rtrim($query, '&');
        return $query;
    }
1319030
protected function buildModel($model)
    {
        try {
            $query = $this->resolveQueryBuilderFromModel($model);
        } catch (InvalidArgumentException $e) {
            $query = $model;
        }

        if ($this->paginate === true && \method_exists($query, 'paginate')) {
            $query = $query->paginate($this->perPage, ['*'], $this->pageName);
        } elseif ($this->isQueryBuilder($query)) {
            $query = $query->get();
        }

        return $query;
    }
480704
protected function scopeQueryToWhereModelIsMissing($query, $modelName)
    {
        $model = new $modelName;
        $table = $this->abilitiesTable();

        $query->where("{$table}.entity_type", $modelName);

        $query->whereNotIn("{$table}.entity_id", function ($query) use ($modelName) {
            $model = new $modelName;
            $table = $model->getTable();

            $query->from($table)->select($table.'.'.$model->getKeyName());
        });
    }