Build a list of SQL conditions to select the current mapped object into DB.

@return string[]
439008
final private function getSqlKeyConditions() {
	
		$class		= get_called_class();
		$tableKey	= (array)$class::TABLE_KEY;
		$conds		= array();
		
			foreach ($tableKey as $field) {
				$conds[] = $this->db->escape($field) . ' = ?';
			}
		
		return $conds;

	}
62856
private function prepareCondition(array $condition): array
    {
        if ($condition['sql'] instanceof self) {
            list($sql, $params) = $condition['sql']->toSql();

            $condition['sql'] = $sql ? '(' . $sql . ')' : null;

            $condition['params'] = $params;
        }

        if ($condition['sql'] instanceof WhereClauseStrategy) {
            list($sql, $params) = $condition['sql']->whereToSql(false);

            $condition['sql'] = $sql ? '(' . $sql . ')' : null;

            $condition['params'] = $params;
        }

        if ($condition['sql'] instanceof HavingClauseStrategy) {
            list($sql, $params) = $condition['sql']->havingToSql(false);

            $condition['sql'] = $sql ? '(' . $sql . ')' : null;

            $condition['params'] = $params;
        }

        return $condition;
    }
311691
public function getRows()
    {
        $rows = [];
        $wheres = $this->queryBuilder->wheres ?: [];

        foreach ($wheres as $where) {

            // Skip unsupported clauses
            if (!isset($where['column'])) {
                continue;
            }

            // If it doesn't contain the table name assume it's the "FROM" table
            if (strpos($where['column'], '.') === false) {
                $where['column'] = implode('.', [$this->queryBuilder->from, $where['column']]);
            }

            list($table, $column) = $this->splitTableAndColumn($where['column']);

            // Make sure that the where clause applies for the primary key column
            if ($column !== self::PRIMARY_KEY_COLUMN) {
                continue;
            }

            // Initialize a set for the current table
            if (!isset($rows[$table])) {
                $rows[$table] = [];
            }

            // Add the rows to the current table set
            if ($where['type'] === 'Basic') {
                if ($where['operator'] === '=' && is_numeric($where['value'])) {
                    $rows[$table][] = $where['value'];
                }
            }
            else if ($where['type'] === 'In') {
                $rows[$table] += $where['values'];
            }
        }

        return $rows;
    }
1043118
protected function buildCondition()
    {
        $column = explode('.', $this->column);

        if (count($column) == 1) {
            return [$this->query => func_get_args()];
        }

        return $this->buildRelationQuery(...func_get_args());
    }
707318
public function getSQLParamNames() : array
   {

      $out = [];

      foreach ( $this->_attributes as $attributeName => $attribute )
      {
         if ( Type::INIT_SQL === $attribute->getType() )
         {
            $out[] = $attributeName;
         }
      }

      return $out;

   }
352342
protected function generateSelectAllSQL()
        {
            $sql_parts = [];
            foreach ($this->query->getSelectionColumns() as $selection) {
                $sql_parts[] = $selection->getSql();
            }
            return implode(', ', $sql_parts);
        }
831857
public function select()
    {
        $fields = !empty($this->fields) ? $this->fields : ["*"];
        if (empty($this->fields)) {
            $fields = isset($this->infosMergeds['fields']) ?
                implode(", ", $this->infosMergeds['fields']) :
                "*";
        }

        $this->sql = new PhiberQueryWriter("select", [
            "table" => $this->table,
            "fields" => $fields,
            "where" => isset($this->infosMergeds['where']) ?
                $this->infosMergeds['where'] :
                null,
            "limit" => isset($this->infosMergeds['limit']) ?
                $this->infosMergeds['limit'] :
                null,
            "offset" => isset($this->infosMergeds['offset']) ?
                $this->infosMergeds['offset'] :
                null,
            "orderby" => isset($this->infosMergeds['orderby']) ?
                $this->infosMergeds['orderby'] :
                null,
            "join" => isset($this->joins) ?
                $this->joins :
                null
        ]);

        $result = [];
        if ($this->phiberConfig->verifyExecuteQueries()) {
            $this->PDO = $this->PDO->prepare($this->sql);
            if (isset($this->infosMergeds['fields_and_values'])) {

                while (current($this->infosMergeds['fields_and_values'])) {
                    $this->PDO->bindValue(
                        "condition_" . key($this->infosMergeds['fields_and_values']),
                        $this->infosMergeds['fields_and_values'][key($this->infosMergeds['fields_and_values'])]);
                    next($this->infosMergeds['fields_and_values']);
                }
            }
            $this->PDO->execute();

            $result = $this->PDO->fetchAll((PDO::FETCH_ASSOC));

            $this->rowCount = $this->PDO->rowCount();
        }

        return $result;
    }
466649
protected function buildQueryString() {

		$w = [];
		$s = [];

		$qc = $this->quoteChar;

		// start SQL statement

		$this->sql = 'SELECT ';

		// add columns

		if(!$this->columns || !count($this->columns)) {
			$this->sql .= '*';
		}
		else {
			
			$this->sql .= $qc . str_replace('.', $qc . '.' . $qc, implode($qc . ',' . $qc, $this->columns)) . $qc;
				
		}

		// add table

		$this->sql .= ' FROM ' . $qc . preg_replace('/\s+/', $qc . ' ' . $qc, $this->table) . $qc;

		// add alias

		if($this->alias) {
			$this->sql .= ' ' . $qc . $this->alias . $qc;
		}

		// add INNER JOINs

		foreach($this->innerJoins as $join) {
			$this->sql .= sprintf(' INNER JOIN %1$s%2$s%1$s ON %3$s', $qc, preg_replace('/\s+/', $qc . ' ' . $qc, trim($join->table)), $join->on);
		}

		// build WHERE clause

		foreach($this->whereClauses as $where) {

			// complete condition when no operator set

			if(!$where->operator) {
				$w[] = $where->conditionOrColumn;
			}

			// otherwise parse operator

			else {
				if($where->operator === 'IN') {
					$w[] = sprintf(
						'%1$s%2$s%1$s IN (%3$s)',
						$qc,
						str_replace('.', $qc . '.' . $qc, $where->conditionOrColumn),
						implode(', ', array_fill(0, count($where->value), '?'))
					);
				}
				else {
					$w[] = sprintf(
						'%1$s%2$s%1$s %3$s ?',
						$qc,
						str_replace('.', $qc . '.' . $qc, $where->conditionOrColumn),
						$where->operator
					);
				}
			}
		}

		// build SORT clause

		foreach($this->columnSorts as $sort) {
			$s[] = $sort->column . ($sort->asc ? '' : ' DESC');
		}

		if(count($w)) {
			$this->sql .= ' WHERE (' . implode(') AND (', $w) .')';
		}
		if(count($s)) {
			$this->sql .= ' ORDER BY ' . implode(', ', $s);
		}

	}
492040
public function prepare() {
        $sql = $this->getSql();
        $params = array_merge($this->whereParams(), $this->having_params);
        return [$sql, $params];
    }
829344
public function get_sql_where() {
        list($where, $params) = parent::get_sql_where();
        $where = preg_replace('/firstname/', 'u.firstname', $where);
        $where = preg_replace('/lastname/', 'u.lastname', $where);
        return [$where, $params];
    }
145070
public function getConditionSql(array $sql, array $where, string $conditionType): array
    {
        if (empty($where)) {
            return $sql;
        }
        foreach ($where as $index => $item) {
            if ($item instanceof RawExp) {
                if ($index == 0) {
                    $sql[] = $conditionType . ' ' . $item->getValue();
                    continue;
                }
                $sql[] = $item->getValue();
                continue;
            }
            [$type, $conditions] = $item;
            if (!$index) {
                $whereType = $conditionType;
            } else {
                $whereType = strtoupper($type);
            }
            if ($conditions[0] instanceof RawExp) {
                $sql[] = $whereType . ' ' . $conditions[0]->getValue();
                continue;
            }
            [$leftField, $operator, $rightField] = $conditions;
            $leftField = $this->quoter->quoteName($leftField);
            [$rightField, $operator] = $this->getRightFieldValue($rightField, $operator);

            $sql[] = sprintf('%s %s %s %s', $whereType, $leftField, $operator, $rightField);
        }

        return $sql;
    }
1266062
protected function getOnConditionSQL($mapping)
    {
        $targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
        $association = ( ! $mapping['isOwningSide'])
            ? $targetClass->associationMappings[$mapping['mappedBy']]
            : $mapping;

        $joinColumns = $mapping['isOwningSide']
            ? $association['joinTable']['inverseJoinColumns']
            : $association['joinTable']['joinColumns'];

        $conditions = array();

        foreach ($joinColumns as $joinColumn) {
            $joinColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform);
            $refColumnName  = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $targetClass, $this->platform);

            $conditions[] = ' t.' . $joinColumnName . ' = ' . 'te.' . $refColumnName;
        }

        return $conditions;
    }
186124
public function getMap()
    {
        $result = [];

        foreach ($this->getConstants() as $dbName => $dbValue) {
            if (0 === strpos($dbName, self::PREFIX_DB)) {
                $result[$dbValue] = $this->getAppropriateConstValue(self::PREFIX_DB, $dbName);
            }
        }

        return $result;
    }
916098
final private function getSqlKeyValues() {
		
		// force to array
		$propertyNames = (array)$this->keyProperties;

		// list to return
		$values = array();

		foreach ($propertyNames as $name) {
			$values[] = $this->{$name};
		}

		return $values;

	}
381728
public function sqlFilters()
    {
        if (!$this->hasFilters()) {
            return '';
        }

        $criteria = $this->createFilter([
            'filters' => $this->filters()
        ]);

        $sql = $criteria->sql();
        if (strlen($sql) > 0) {
            $sql = ' WHERE '.$sql;
        }

        return $sql;
    }
348756
protected function buildConditionFromRequest()
    {
        $request = $this->getRequest();
        $post = $request->request->getIterator();
        $serviceId = $request->request->get('categoryCondition');
        $operators = [];
        $values = [];
        foreach ($post as $key => $input) {
            if (isset($input['operator']) && isset($input['value'])) {
                $operators[$key] = $input['operator'];
                $values[$key] = $input['value'];
            }
        }

        /** @var ConditionFactory $conditionFactory */
        $conditionFactory = $this->container->get('thelia.condition.factory');
        $conditionToSave = $conditionFactory->build($serviceId, $operators, $values);

        return $conditionToSave;
    }
570569
public function selectAll() {
        // Build Select Command
        $sql_query = 'SELECT ' . $this->_distinct .
                     '* FROM ' . $this->_table;

        if (count($this->_joins)) {
            $sql_query .= implode($this->_joins, ' ');
        }
        
        // Where statements
        if (count($this->_where)) {
            $sql_query .= ' WHERE ';
            $sql_query .= implode($this->_where, ' AND ');
            
            // or statements
            if (count($this->_or)) {
                $sql_query .= ' OR ';
                $sql_query .= implode($this->_or, ' AND ');
            }
        }
        
        // Alias
        if ($this->_alias) {
            $sql_query .= ' AS ' . $this->_alias;
        }
        
        // Union
        if (count($this->_union)) {
            $sql_query .= ' UNION ' . implode($this->_union, ' UNION ');
        }
        
        // Union All
        if (count($this->_union_all)) {
            $sql_query .= ' UNION ALL ' . implode($this->_union_all, ' UNION ALL ');
        }
        
        // Group By
        if (strlen($this->_group_by)) {
            $sql_query .= $this->_group_by;
        }
        
        // Order By
        if (strlen($this->_order)) {
            $sql_query .= $this->_order;
        }
        
        // Limit
        if (strlen($this->_limit)) {
            $sql_query .= $this->_limit;
        }
        
        // Set the query
        $this->_sql_query = $sql_query;
        
        return $this;
    }