Axel
Axel

Reputation: 61

Concat_ws in propel

how can I modify my propel query to get the same result as the following MySQL query ?

SELECT v.id,CONCAT_WS(" ",b.name,v.model) AS car_name
FROM vehicle v
JOIN account_vehicle av ON av.account_id=:uid
LEFT JOIN brands b ON b.id=v.manufacturer
WHERE av.vehicle_id=v.id

Right now i have something like that

$query = VehicleQuery::create('v')
->joinAccountVehicle('av')
->leftJoinBrands('b')
->select(array('v.Id', 'b.Name', 'v.Model'))
->where('av.VehicleId=v.Id')
->find();

How can i modify the propel use - to get the same result ? I'm having difficulties with the concat_ws function in propel. I've tried using the Criteria model - but I cant add the joined table (criteria requires TABLEPEER:COLUMN_NAME's and rejects my aliases)

Upvotes: 2

Views: 147

Answers (1)

Suresh Kamrushi
Suresh Kamrushi

Reputation: 16086

Try something like this:

$query = VehicleQuery::create('v')
->joinAccountVehicle('av')
->leftJoinBrands('b')
->select(array('v.Id', 'b.Name', 'v.Model','CONCAT_WS(" ",b.name,v.model) AS car_name'))
->where('av.VehicleId=v.Id')
->find();

Upvotes: 1

Related Questions