Cannot use a scalar value as an array when doing two or more left joins

The Class

class Places extends \Phalcon\Mvc\Model
{
 public function getValuesById($id=null){
        $dataset = $this->query()
            ->leftJoin('Cities','c.city_id=Places.fk_city_id','c')                
            ->leftJoin('States', 's.state_id = Places.fk_state_id', 's')
            ->where('place_id = :id:',array("id" => $id),'int')
            ->execute();
    }
}

The Call

$placeObject= New Places();
$placeObject->getValuesById($this->dispatcher->getParam("id",'int'));

The Error (it is printed 16 times)

Notice: Cannot use a scalar value as an array in C:\www\mexicohermoso.com\thor\app\models\Places.php on line 37

The Exception

PhalconException: Scanning error before '] JOIN [] JOIN [...' when parsing: SELECT [Places].* FROM [Places] LEFT JOIN [Cities] AS [c] ON c.city_id=Places.fk_city_id JOIN [] JOIN [] JOIN [] JOIN [] WHERE place_id = :id: (142)

More Details>

If I remove the States left Join, it will work just fine, also it will work flawlessly  if it is executed from within the controller ($this->modelsManager->createBuilder())

ideas?



1.1k
edited Mar '14

Hi, I have the same error, although a little different situation. A inner join B and B inner join C. Have you found a solution, because I think the problem might be the same?

Thanks.

         $drivers = parent::query()
                ->columns(array('status', 'color'))
                ->where('id_driver_to_car = :id:')
                ->bind(array('id'=>1))
                ->innerJoin('Gtn\Model\Car', 'Gtn\Model\Drivertocar.id_car = Gtn\Model\Car.id_car')
                ->innerJoin('Gtn\Model\Car.Gtn\Model\CarDocument','Gtn\Model\Car.id_car_document = Gtn\Model\Cardocument.id_car_document')
                ->execute();

        return $drivers;


12.6k

@mullermx I have the same issue. Have you opened a bug report on Github. It is a critial bug.