I'm having difficulties querying the database using the OO notation to build queries if I use more than one join (INNER in my case). Here is the code:
$query = $this->query() ->columns('Products.id, product_name, product_key, sku') ->join('Skus', 'Products.id = Skus.product_id', 's') ->join('Clients', 'Products.client_id = Clients.id') ->where('client_hash = :client_id:') ->where('product_key = :product_key:') ->bind(array('client_id' => $client_id, 'product_key' => $product_key)) ;
The table I'm querying on belongs to "Client" and has many "Skus" — all those relationships are defined in the models in the initialize() method.
When I try to execute() the resulting query, I get the following exception:
PhalconException: Scanning error before '] JOIN  JOIN [...' when parsing: SELECT Products.id, productname, productkey, sku FROM [Products] JOIN [Skus] AS [s] ON Products.id = Skus.productid JOIN  JOIN  JOIN  JOIN  WHERE productkey = :product_key: (184)
The join works perfectly when I use only one join — either Skus or Clients.
Is this a bug or is there something I'm missing?