framework/db/QueryBuilder.php
public function createView($viewName, $subQuery)
    {
        if ($subQuery instanceof Query) {
            list($rawQuery, $params) = $this->build($subQuery);
            array_walk(
                $params,
                function(&$param) {
                    $param = $this->db->quoteValue($param);
                }
            );
            $subQuery = strtr($rawQuery, $params);
        }

        return 'CREATE VIEW ' . $this->db->quoteTableName($viewName) . ' AS ' . $subQuery;
    }
public function createView($viewName, $subQuery)
    {
        if ($subQuery instanceof Query) {
            list($rawQuery, $params) = $this->build($subQuery);
            array_walk(
                $params,
                function(&$param) {
                    $param = $this->db->quoteValue($param);
                }
            );
            $subQuery = strtr($rawQuery, $params);
        }

        return 'CREATE VIEW ' . $this->db->quoteTableName($viewName) . ' AS ' . $subQuery;
    }
Creates a SQL View.

@param string $viewName the name of the view to be created.
@param string|Query $subQuery the select statement which defines the view.
This can be either a string or a [[Query]] object.
@return string the `CREATE VIEW` SQL statement.
@since 2.0.14