Get query statement of current cursor.

@param mixed $type

@return \PDOStatement
161304
public function getStatement($type = null)
    {
        if (is_null($this->statement)) {
            $this->buffer = array();
            $this->next = false;

            $sql = "SELECT * FROM {$this->connection->getDialect()->grammarEscape($this->collection->getName())}";

            $wheres = array();
            $data = array();

            foreach ($this->criteria as $key => $value) {
                $wheres[] = $a= $this->connection->getDialect()->grammarExpression(
                    $key,
                    $value,
                    $this->collection,
                    $data
                );
            }

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

            if (isset($this->sorts)) {
                $sorts = array();

                foreach ($this->sorts as $key => $value) {
                    if ($value == 1) {
                        $op = ' ASC';
                    } else {
                        $op = ' DESC';
                    }

                    $sorts[] = $this->connection->getDialect()->grammarEscape($key).$op;
                }

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

            if (isset($this->limit) || isset($this->skip)) {
                $sql .= ' LIMIT '.($this->limit ?: -1).' OFFSET '.($this->skip ?: 0);
            }

            
            $this->statement = $this->connection->getRaw()->prepare($sql);

            $this->statement->execute($data);
        }

        return $this->statement;
    }
1220019
public static function getLogger($type) {
        if (!isset(self::$Loggers[$type])) {
            self::$Loggers[$type] = self::createLogger($type);
        }
        return self::$Loggers[$type];
    }
841994
public function isType($type)
    {
        if (!$this->isTypeSupported($type)) {
            throw new Exception('Unsupported query type');
        }

        return isset($this->parsedSql[$type]);
    }
1266921
public function getOriginalQuery($type = null)
    {
        if ($type !== null) {
            return $this->originalQueries[$type];
        }

        return reset($this->originalQueries);
    }
436263
public function &PreviousRow($DatasetType = FALSE) {
      $Result = &$this->Result($DatasetType);
      --$this->_Cursor;
      if (isset($Result[$this->_Cursor])) {
         return $Result[$this->_Cursor];
      }
      return $this->_EOF;
   }
435684
public function getColumnQuery() {
        // prepare column types
        $type_val = $this->getTypeVal();
        // build query
        $query = $this->db->quotekey($this->name).' '.$type_val.' '.
            $this->getNullable();
        // unify default for booleans
        if (preg_match('/bool/i', $type_val) && $this->default!==null)
            $this->default = (int) $this->default;
        // default value
        if ($this->default !== false) {
            $def_cmds = array(
                'sqlite2?|mysql|pgsql' => 'DEFAULT',
                'mssql|sybase|dblib|odbc|sqlsrv' => 'constraint DF_'.$this->table->name.'_'.$this->name.' DEFAULT',
                'ibm' => 'WITH DEFAULT',
            );
            $def_cmd = $this->findQuery($def_cmds).' '.$this->getDefault();
            $query .= ' '.$def_cmd;
        }
        if (!empty($this->after) && $this->table instanceof TableModifier) {
            // `after` feature only works for mysql
            if (preg_match('/mysql/', $this->db->driver())) {
                $after_cmd = 'AFTER '.$this->db->quotekey($this->after);
                $query .= ' '.$after_cmd;
            }
        }
        return $query;
    }
95259
public function getPdoStatement(\PDO $pdo)
    {
        $stmt = $pdo->prepare($this->getSqlString());

        $bound = $this->getBoundValues();

        foreach ($bound as $name => $bind) {
            $stmt->bindValue($name, $bind[0], $bind[1]);
        }

        return $stmt;
    }
1262840
public function getQuery()
    {
        $query = null;

        switch ($this->type) {
            case self::SELECT:
                $query = $this->getSelectQuery();
                break;
            case self::INSERT:
                $query = $this->getInsertQuery();
                break;
            case self::UPDATE:
                $query = $this->getUpdateQuery();
                break;
            case self::DELETE:
                $query = $this->getDeleteQuery();
                break;
        }

        return $query;
    }
15428
protected function typeToPDOParamType($type)
    {
        switch ($type) {
        case "boolean":
            return PDO::PARAM_BOOL;
        case "integer":
            return PDO::PARAM_STR;
        case "NULL":
            return PDO::PARAM_NULL;
        case "resource":
            return PDO::PARAM_LOB;
        case "double":
        case "string":
        default:
            return PDO::PARAM_STR;
        }
    }
308580
private function getHandler($type)
    {
        if (!isset(self::$typeHandlers[$type])) {
            throw new Exception("Unsupported PDO param type - " . $type);
        }

        return self::$typeHandlers[$type];
    }
757211
public function findByType($type, $executeQuery = true)
    {
        $queryBuilder = $this->createQueryBuilder('w')
            ->andWhere($this->getWigetInstanceString($type))
        ;

        return $executeQuery ? $queryBuilder->getQuery()->getResult() : $queryBuilder->getQuery();
    }
533818
public function fetchAll($type = null)
    {
        try {
            if ($this->res === false) {
                throw new DatabaseException(__METHOD__ . " No ressource has been given", MySQL::NO_RESSOURCE, MySQL::SEVERITY_DEBUG, __FILE__, __LINE__);
            }

            switch ($type) {
                case MySQL::FETCH_ASSOC:
                    return $this->_db->fetch_assoc_list($this->res);
                    break;
                case MySQL::FETCH_NUM:
                    return $this->_db->fetch_num_list($this->res);
                    break;
                case MySQL::FETCH_OBJ:
                default:
                    return $this->_db->fetch_object_list($this->res);
                    break;
            }
        } catch (DatabaseException $e) {
            throw $e;
        }


    }
551104
public function fetch($fetchType = 'assoc')
    {
        if ($fetchType === 'num') {
            return $this->statement->fetch(\PDO::FETCH_NUM);
        } elseif ($fetchType === 'assoc') {
            return $this->statement->fetch(\PDO::FETCH_ASSOC);
        } elseif ($fetchType === 'obj') {
            return $this->statement->fetch(\PDO::FETCH_OBJ);
        }
    }
182790
public static function getMeasures($type)
    {
        /** @var ActiveQuery $query */
        $query = static::find()->select(['name', 'id'])->indexBy('id');
        if (empty($type) === false) {
            $query->where(['type' => $type]);
        }
        return $query->column();
    }
799431
public function getFilteredQuery($status, $type)
    {
        $query = $this->createQueryBuilder('n');

        if (is_int($status) && in_array($status, NoticeEntity::getStatuses())) {
            $query
                ->where('n.status = :status')
                ->setParameter('status', $status);
        }

        if ($type) {
            $query
                ->andWhere('n.type = :type')
                ->setParameter('type', $type);
        }

        return $query;
    }
1170119
public function getChanges($type)
	{
		if ( ! isset($this->changes[$type]))
		{
			return null;
		}

		return $this->changes[$type];
	}
796829
private function doInsert(array $data, string $type)
    {
        // Insert single item

        if (\is_array(current($data)) === false) {
            $queryObject = $this->getQuery($type, $data);

            $this->connection->setLastQuery($queryObject);

            $this->fireEvents(EventHandler::EVENT_BEFORE_INSERT, $queryObject);
            /**
             * @var $result        \PDOStatement
             * @var $executionTime float
             */
            [$result, $executionTime] = $this->statement($queryObject->getSql(), $queryObject->getBindings());

            $insertId = $result->rowCount() === 1 ? $this->pdo()->lastInsertId() : null;
            $this->fireEvents(EventHandler::EVENT_AFTER_INSERT, $queryObject, [
                'insert_id'      => $insertId,
                'execution_time' => $executionTime,
            ]);

            return $insertId;
        }

        $insertIds = [];

        // If the current batch insert is not in a transaction, we create one...

        if ($this->pdo()->inTransaction() === false) {

            $this->transaction(function (Transaction $transaction) use (&$insertIds, $data, $type) {
                foreach ($data as $subData) {
                    $insertIds[] = $transaction->doInsert($subData, $type);
                }
            });

            return $insertIds;
        }

        // Otherwise insert one by one...
        foreach ($data as $subData) {
            $insertIds[] = $this->doInsert($subData, $type);
        }

        return $insertIds;
    }