Optional named parameters.


@param string[] $attributes
@param string $from
@param string $where
@param string[] $params
@param string $group_by
@param string $order_by
@param int $limit
@param int $start
@return \PDOStatement
515517
public function sqlSelect(
		array $attributes,
		$from,
		$where = null,
		array $params = [],
		$group_by = null,
		$order_by = null,
		$limit = null,
		$start = 0
	) {
		$sql = $this->queryBuilder->buildSelect(
			$attributes,
			$from,
			$where,
			$group_by,
			$order_by,
			$limit,
			$start
		);
		$query = $this->database->prepare($sql);
		$query->execute($params);
		$this->addQuery($query->queryString, $params);
		return $query;
	}
1260381
public function findWhereIn(array $where, $attributes = ['*'])
    {
        return $this->executeCallback(get_called_class(), __FUNCTION__, func_get_args(), function () use ($where, $attributes) {
            list($attribute, $values, $boolean, $not) = array_pad($where, 4, null);

            $this->whereIn($attribute, $values, $boolean, $not);

            return $this->prepareQuery($this->createModel())->get($attributes);
        });
    }
592030
public function getQueryColumn($parameters, $attribute)
    {
        return isset($parameters[1]) && $parameters[1] !== 'NULL'
                    ? $parameters[1] : $this->guessColumnForQuery($attribute);
    }
957193
protected static function firstByAttributes($attributes)
	{
		$query = static::query();

		foreach ($attributes as $key => $value)
		{
			$query->where($key, $value);
		}

		return $query->first() ?: null;
	}
811308
public function whereRange(Array $attributes)
    {
        foreach ($attributes as $attribute => $value){
            $from = $value[0];
            $to = $value[1];

            if(!empty($from) || !empty($to)){
                if(!empty($from) && empty($to)){
                    $this->andFilterWhere(['>=', $attribute, (int)$from]);
                } elseif(!empty($to) && empty($from)) {
                    $this->andFilterWhere(['<=', $attribute, (int)$to]);
                } else {
                    $this->andFilterWhere(['between', $attribute, (int)$from, (int)$to]);
                }
            }
        }
        return $this;
    }
1131155
private function convertParameters(array $parameters, $type, \DOMElement $parent, $keyAttribute = 'key')
    {
        $withKeys = array_keys($parameters) !== range(0, count($parameters) - 1);
        foreach ($parameters as $key => $value) {
            $element = $this->document->createElement($type);
            if ($withKeys) {
                $element->setAttribute($keyAttribute, $key);
            }

            if ($value instanceof ServiceClosureArgument) {
                $value = $value->getValues()[0];
            }
            if (is_array($value)) {
                $element->setAttribute('type', 'collection');
                $this->convertParameters($value, $type, $element, 'key');
            } elseif ($value instanceof TaggedIteratorArgument) {
                $element->setAttribute('type', 'tagged');
                $element->setAttribute('tag', $value->getTag());
            } elseif ($value instanceof IteratorArgument) {
                $element->setAttribute('type', 'iterator');
                $this->convertParameters($value->getValues(), $type, $element, 'key');
            } elseif ($value instanceof Reference) {
                $element->setAttribute('type', 'service');
                $element->setAttribute('id', (string) $value);
                $behaviour = $value->getInvalidBehavior();
                if (ContainerInterface::NULL_ON_INVALID_REFERENCE == $behaviour) {
                    $element->setAttribute('on-invalid', 'null');
                } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE == $behaviour) {
                    $element->setAttribute('on-invalid', 'ignore');
                } elseif (ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE == $behaviour) {
                    $element->setAttribute('on-invalid', 'ignore_uninitialized');
                }
            } elseif ($value instanceof Definition) {
                $element->setAttribute('type', 'service');
                $this->addService($value, null, $element);
            } elseif ($value instanceof Expression) {
                $element->setAttribute('type', 'expression');
                $text = $this->document->createTextNode(self::phpToXml((string) $value));
                $element->appendChild($text);
            } else {
                if (in_array($value, array('null', 'true', 'false'), true)) {
                    $element->setAttribute('type', 'string');
                }
                $text = $this->document->createTextNode(self::phpToXml($value));
                $element->appendChild($text);
            }
            $parent->appendChild($element);
        }
    }
1060008
public static function create($attributes = [])
    {
        try {
            self::init();
            foreach ($attributes as $column => $value) {
                $columns[] = $column;
                $values[] = ':'.$column;
            }

            $sql = 'INSERT INTO ' . self::$modelTable . ' (' . implode(',', $columns) . ') VALUES (' . implode(',', $values) . ')';
            $stm = self::$connect->prepare($sql);
            $stm->execute($attributes);
            return self::find(self::$connect->lastInsertId());
        } catch (\Exception $exception) {
            var_dump($exception->getMessage());
        }
    }
415218
protected function copyParam($from, $target, $param, $default)
    {
        // param has been changed
        if (strpos($from, sprintf($param, $default)) === false) {
            list($left, $right) = explode('%s', $param);
            $start = strpos($from, $left) + strlen($left);
            $end = strpos($from, $right, $start);
            $value = substr($from, $start, $end - $start);
            $target = str_replace(sprintf($param, $default), sprintf($param, $value), $target);
        }

        return $target;
    }
318423
public function addGroupSelect($options, $columnIndex = 0, $defaultSelected = null, array $attributes = [])
    {
        $orderAdapter = app(OrderAdapter::class)->setClassname(get_class($this->datatable));
        if (($order        = $orderAdapter->getSelected()) !== false) {
            $this->parameters([
                'order' => [[$order['column'], $order['dir']]],
            ]);
        }
        $groupsFilter = app(GroupsFilterAdapter::class)->setClassname(get_class($this->datatable))->setIndex($columnIndex);
        $data         = ($options instanceof Collection) ? $options->toArray() : $options;
        if ($defaultSelected) {
            $this->selectedGroups[$columnIndex] = $defaultSelected;
        }

        $id    = array_get($this->tableAttributes, 'id') . '-filter-group';
        if (is_null($value = $groupsFilter->getSelected($columnIndex))) {
            $value = $defaultSelected;
        }

        $decorated = $this->html->decorate($attributes, [
            'data-selectar--mdl-big' => "true",
            'class'                  => 'mb24 select2-left select--category select2--prefix',
            'id'                     => $id,
            'data-select2--class'    => 'card-ctrls--select2'
        ]);

        $html = Form::select('category', $data, $value, $decorated);
        $groupsFilter->scripts(array_get($decorated, 'id'), $columnIndex);
        array_push($this->selects, $html);
        return $this;
    }
951260
public function setFrom($from)
    {
        $attr = $this->createAttribute('from');
        $this->doc->appendChild($attr);
        $attr->appendChild($this->createTextNode($from));
    }
1344192
public function addWhereByAttributes($attributes, $operator = 'AND')
    {
        $t = [];
        $params = [];
        foreach ($attributes as $k => $v) {
            if ($v instanceof Expression) {
                $t[] = $this->quoteColumnName($k) . '=' . $v->expression;
                continue;
            }
            $bk = $this->getBindKey();
            $params[$bk] = $v;
            $t[] = $this->quoteColumnName($k) . '=' . $bk;
        }
        return $this->addWhere(implode(' AND ', $t), $params, $operator);
    }
976284
public function delete($where = null, $params = [], $limit = null, $order = null) {

		if(null === $this -> getAdapter()) {
			return trigger_error(sprintf('No database adapter was set in "%s"', __METHOD__), E_USER_ERROR);
		}

		if(null !== $where && false === is_string($where)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($where)), E_USER_ERROR);
		}

		if(false === is_array($params)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR);
		}

		if(null !== $limit && false === is_string($limit)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($limit)), E_USER_ERROR);
		}

		if(null !== $order && false === is_string($order)) {
			return trigger_error(sprintf('Argument 5 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($order)), E_USER_ERROR);
		}

		//Select
		$query[] = sprintf('DELETE FROM %s', $this -> getAdapter() -> escape($this -> getTable()));

		//Where
		if(null !== $where) {
			$query[] = sprintf('WHERE %s', $this -> getAdapter() -> escape($where));
		}

		//Order
		if(null !== $order) {
			$query[] = sprintf('ORDER BY %s', $this -> getAdapter() -> escape($order));			
		}

		//Limit
		if(null !== $limit) {
			$query[] = sprintf('LIMIT %s', $this -> getAdapter() -> escape($limit));
		}

		return $this -> getAdapter() -> query(implode(' ', $query), $params) -> execute();
	}
461746
public function parameterize($attributes = [])
    {
        $parameters = (new Parameters($attributes))->toArray();

        $values = [];
        $replacements = [];

        foreach (array_dot($parameters) as $key => $value) {
            if ($this->isCallbackFunction($value, $key)) {
                $values[] = trim($value);
                array_set($parameters, $key, '%' . $key . '%');
                $replacements[] = '"%' . $key . '%"';
            }
        }

        $new = [];
        foreach ($parameters as $key => $value) {
            array_set($new, $key, $value);
        }

        $json = json_encode($new);

        $json = str_replace($replacements, $values, $json);

        return $json;
    }
720028
public function limit($from, $to = '') 
    {
        $this->sql .= ' LIMIT ' . $from;
        
        if(is_numeric($to)) {
            $this->sql .= ', ' . $to;
        }
        
        return $this;
    }
1076031
public function createComparatorConstraint(Attributes $attributes): ComparatorConstraint {
		return new SimpleComparatorConstraint($this->criteriaProperty,
				$attributes->reqEnum(self::OPERATOR_OPTION, $this->getOperators()),
				N2nLocale::build($attributes->getString(self::ATTR_VALUE_KEY, false, null, true)));
	}
1362721
public function rawQuery($sql, array $attributes = [], $connection = null)
    {
        if (empty($this->statements[$sql]))
        {
            $this->statements[$sql] = $this->connection($connection)->prepare($sql);
        }

        $this->statements[$sql]->execute($attributes);

        return $this->statements[$sql];
    }
912893
public function from($from, $from_name = '')
    {
        $this->from      = $from;
        $this->from_name = $from_name;
        return $this;
    }