Yii 2 Query Builder with strange backticks

 $query = (new Query())
            ->select(['itinerary.id, itinerary.from_vertex_id, itinerary.to_vertex_id,
             v1.name AS from_name, v2.name AS to_name, 
             CONCAT(v1.name, v2.name) AS it_name
            ->innerJoin('vertex v1', 'itinerary.from_vertex_id = v1.id')
            ->innerJoin('vertex v2', 'itinerary.to_vertex_id = v2.id')

Solution: The select method above must always be passed with an array ( [] ), using it with string puts strange backticks around column names.

Leave a Comment

Your email address will not be published. Required fields are marked *