@param AbstractSpatialType $type
@param string              $sqlExpr

@return string
512867
public function convertToPHPValueSQL(AbstractSpatialType $type, $sqlExpr)
    {
        if ($type instanceof GeographyType) {
            return sprintf('ST_AsEWKT(%s)', $sqlExpr);
        }

        return sprintf('ST_AsEWKB(%s)', $sqlExpr);
    }
942538
public function setSqlType($sqlType)
    {
        if (!is_string($sqlType)) {
            throw new InvalidArgumentException(
                'SQL Type must be a string.'
            );
        }

        switch (strtoupper($sqlType)) {
            case 'TEXT':
                $sqlType = 'TEXT';
                break;

            case 'TINY':
            case 'TINYTEXT':
                $sqlType = 'TINYTEXT';
                break;

            case 'MEDIUM':
            case 'MEDIUMTEXT':
                $sqlType = 'MEDIUMTEXT';
                break;

            case 'LONG':
            case 'LONGTEXT':
                $sqlType = 'LONGTEXT';
                break;

            default:
                throw new InvalidArgumentException(
                    'SQL Type must be one of TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT.'
                );
        }

        $this->sqlType = $sqlType;

        return $this;
    }
819169
public function getRanges($type, $includeExpired = false)
    {
        $sql = 'SELECT * FROM LoginControlIpRanges WHERE lcirType = ?';
        $params = [(int) $type];
        if (!$includeExpired) {
            $sql .= ' AND (lcirExpires IS NULL OR lcirExpires > ' . $this->connection->getDatabasePlatform()->getNowExpression() . ')';
        }
        $sql .= ' ORDER BY lcirID';
        $result = [];
        $dateTimeFormat = $this->connection->getDatabasePlatform()->getDateTimeFormatString();
        $rs = $this->connection->executeQuery($sql, $params);
        while (($row = $rs->fetch()) !== false) {
            yield IPRange::createFromRow($row, $dateTimeFormat);
        }
    }
1124077
function (type) {
            var sql = [("" + type).toUpperCase()];
            try {
                this._static[sql + "_CLAUSE_METHODS"].forEach(function (m) {
                    if (m.match("With")) {
                        this[m](sql);
                    } else {
                        var sqlRet = this[m]();
                        if (sqlRet) {
                            sql.push(sqlRet);
                        }
                    }
                }, this);
            } catch (e) {
                throw e;
            }
            return sql.join("");
        }
765424
public function query($query, $type = '')
    {
        try {
            return mssql_query($query, $this->conn);
        } catch (\Exception $e) {
            $this->error = $e->getMessage();

            return null;
        }
    }
581710
public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
    {
        return $this->getSpatialPlatform($platform)->convertToDatabaseValueSQL($this, $sqlExpr);
    }
1165587
public function hint($type, AbstractBuilder $expression)
    {
        return $this->raw([
            'type' => BinaryOperator::OPERATOR_TYPE_HINT,
            'left' => $type,
            'right' => $expression,
        ]);
    }
757211
public function findByType($type, $executeQuery = true)
    {
        $queryBuilder = $this->createQueryBuilder('w')
            ->andWhere($this->getWigetInstanceString($type))
        ;

        return $executeQuery ? $queryBuilder->getQuery()->getResult() : $queryBuilder->getQuery();
    }
883249
public function query($sql, $query_type = null, $result_type = null) {

		if($this->db === null) $this->connect();

		try {

			// SELECT
			if($query_type === \HybridLogic\DB::SELECT) {

				$stmt = $this->db->query($sql);

				if($result_type === null) {
					$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
				} else {
					$results = $stmt->fetchAll(\PDO::FETCH_CLASS, $result_type);
				}

				return $results;

			}

			// INSERT, UPDATE & DELETE
			$rows_affected = $this->db->exec($sql);

			if($query_type === \HybridLogic\DB::INSERT) {
				$result = array(
					'insert_id'     => $this->db->lastInsertId(),
					'rows_affected' => $rows_affected,
				);
			} else {
				$result = $rows_affected;
			}

			return $result;

		} catch(\PDOException $e) {
			throw new \HybridLogic\DB\Exception\QueryException($e);
		}

	}
647674
public function convertToPHPValueSQL($sqlExpr, $platform)
    {
        if ($platform instanceof MySqlPlatform) {
            return sprintf('AsText(%s)', $sqlExpr);
        } else {
            return parent::convertToPHPValueSQL($sqlExpr, $platform);
        }
    }
1177916
private function makeSql(int $type, string $sql, int $count): string
    {
        switch ($type) {
            case self::TYPE_FUNCTION_QUERY:
                $limit = $count !== self::UNLIMIT ? sprintf('limit %s', $count) : '';
                $result = vsprintf('select * from %s %s', [$sql, $limit,]);
                break;
            case self::TYPE_FUNCTION_CURSOR:
                $fetch = $count === self::UNLIMIT ? 'all' : 'FORWARD ' . $count;
                $result = vsprintf('select %s; fetch %s from _result;', [$sql, $fetch,]);
                break;
            case self::TYPE_SIMPLE_QUERY:
            default:
                $result = $sql;
        }

        return $result;
    }
1192430
public function getHandlerForType(string $type) : HandlerInterface
    {
        if ($this->hasHandlerForType($type)) {
            return $this->handlers[$type];
        }

        throw DataTypeException::handlerNotFound($type);
    }
97572
public function convertBinaryToPHPValue(AbstractSpatialType $type, $sqlExpr)
    {
        $parser = new BinaryParser($sqlExpr);

        return $this->newObjectFromValue($type, $parser->parse());
    }
1074645
protected function getResultsByType($type)
    {
        $instance = $this->createModelByType($type);

        $ownerKey = $this->ownerKey ?? $instance->getKeyName();

        $query = $this->replayMacros($instance->newQuery())
                            ->mergeConstraintsFrom($this->getQuery())
                            ->with($this->getQuery()->getEagerLoads());

        return $query->whereIn(
            $instance->getTable().'.'.$ownerKey, $this->gatherKeysByType($type)
        )->get();
    }
184566
private function getExressionValue($expressionType)
    {
        if (!array_key_exists($expressionType, $this->expressionValues)) {
            $expressions = $this->getExpressions();
            $likeIndex = null;

            /* @var $expr Expression */
            foreach ($expressions as $index => $expr) {
                if ($expr->getExpression() === $expressionType) {
                    $likeIndex = $index;
                    break;
                }
            }

            if (!$likeIndex) {
                return null;
            }

            /* @var $field Expression */
            $field = $expressions[$likeIndex + 1];
            $this->expressionValues[$expressionType] = $field->getExpression();
            $noQuotes = $field->getNoQuotes();

            if ($noQuotes) {
                $this->expressionValues[$expressionType] = $noQuotes->getPartsAsString();
            }
        }

        return $this->expressionValues[$expressionType];
    }
1097617
private static function processType(Type $type)
    {
        // TODO type-resolver v1 compat
        // if ($type instanceof AbstractList) {
        if ($type instanceof Array_) {
            return self::flatmap(function ($t) {
                return self::processType($t);
            }, [$type->getKeyType(), $type->getValueType()]);
        }

        if ($type instanceof Compound) {
            return self::flatmap(function ($t) {
                return self::processType($t);
            }, iterator_to_array($type));
        }

        if ($type instanceof Nullable) {
            return self::processType($type->getActualType());
        }

        if ($type instanceof Object_) {
            if (($fq = $type->getFqsen()) !== null) {
                return [ltrim((string) $fq, '\\')];
            }
        }

        return [];
    }
499307
public function getStatement($type = null)
    {
        $data = array();
        $wheres = array();
        $matchOrs = array();

        if (is_null($this->match)) {
            $criteria = $this->translateCriteria($this->criteria);
            
            if ($criteria) {
                foreach ($criteria as $key => $value) {
                    $wheres[] = $this->dialect->grammarExpression($key, $value,$this->collection, $data);
                }
            }
        } else {
            $schema = $this->collection->schema();

            $i = 0;

            foreach ($schema as $key => $value) {
                if ($value instanceof \Norm\Schema\Reference) {
                    $foreign = $value['foreign'];
                    $foreignLabel = $value['foreignLabel'];
                    $foreignKey = $value['foreignKey'];
                    $matchOrs[] = $this->getQueryReference($key, $foreign, $foreignLabel, $foreignKey, $i);
                } else {
                    $matchOrs[] = $key.' LIKE :f'.$i;
                    $i++;
                }
            }

            $wheres[] = '('.implode(' OR ', $matchOrs).')';
        }

        $select  = '';

        if ($this->skip > 0 or $this->limit > 0) {
            $select .= 'rownum r, ';
        }

        $select  .= $this->collection->getName().'.*';
        $query   = 'SELECT '.$select.' FROM '.$this->collection->getName();
        $order   = '';

        if ($this->sortBy) {
            foreach ($this->sortBy as $key => $value) {
                if ($value == 1) {
                    $op = ' ASC';
                } else {
                    $op = ' DESC';
                }
                $order[] = $key . $op;
            }

            if (!empty($order)) {
                $order = ' ORDER BY '.implode(',', $order);
            }
        }

        if (!empty($wheres)) {
            $query .= ' WHERE '.implode(' AND ', $wheres);
        }

        $limit = '';

        if ($this->skip > 0) {
            $limit = 'r > '.($this->skip).' AND ROWNUM <= (SELECT COUNT(ROWNUM) FROM ('.$query.'))';

            if ($this->limit > 0) {
                $limit = 'r > '.($this->skip).' AND ROWNUM <= ' . $this->limit;
            }
        } elseif ($this->limit > 0) {
            $limit = 'r <= ' . $this->limit;
        }

        $query .= $order;

        if ($limit !== '') {
            $query = 'SELECT * FROM ('.$query.') WHERE '.$limit;
        }
        
        $statement = oci_parse($this->raw, $query);

        foreach ($data as $key => $value) {
            oci_bind_by_name($statement, ':'.$key, $data[$key]);
        }

        if ($matchOrs) {
            
            $match = '%'.$this->match.'%';

            foreach ($matchOrs as $key => $value) {
                oci_bind_by_name($statement, ':f'.$key, $match);
            }
        }
        
        oci_execute($statement);

        $result = array();

        while ($row = oci_fetch_array($statement, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
            $result[] = $row;
        }


        $this->rows = $result;

        oci_free_statement($statement);

        $this->index = -1;

    }