We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Join same columns name with related models

For example i have something like this:

$results = $modelsManager->createBuilder()
            ->columns(array('CarBrand.name','model','type','Car.addDate','Admin.addDate','Admin.login','Admin.id','registrationNumber','vin','drivingGear','gearBox','color','mainPicture','sold','soldDate','price','displayName','year','power','capacity','fuel','origin','state'))
            ->from(array('Car'=>'Samochody\Models\Car\Car'))
            ->leftJoin('Samochody\Models\CarBrand\CarBrand',null,'CarBrand')
            ->leftJoin('Samochody\Models\Admin\Admin',null,'Admin')
            ->limit(10,$offset)
            ->getQuery()
            ->execute();

But there are only one addDate only for Car, there are not addDate for Admin

This is how generated query looks like:

SELECT `CarBrand`.`name` AS `name`, `Car`.`model` AS `model`, `Car`.`type` AS `type`, `Admin`.`add_date` AS `addDate`, `Admin`.`login` AS `login`, `Admin`.`id` AS `id`, `Car`.`registration_number` AS `registrationNumber`, `Car`.`vin` AS `vin`, `Car`.`driving_gear` AS `drivingGear`, `Car`.`gear_box` AS `gearBox`, `Car`.`color` AS `color`, `Car`.`main_picture` AS `mainPicture`, `Car`.`sold` AS `sold`, `Car`.`sold_date` AS `soldDate`, `Car`.`price` AS `price`, `Car`.`display_name` AS `displayName`, `Car`.`year` AS `year`, `Car`.`power` AS `power`, `Car`.`capacity` AS `capacity`, `Car`.`fuel` AS `fuel`, `Car`.`origin` AS `origin`, `Car`.`state` AS `state` FROM `car` AS `Car`  LEFT JOIN `car_brand` AS `CarBrand` ON `Car`.`brand` = `CarBrand`.`id` LEFT JOIN `admin` AS `Admin` ON `Car`.`admin` = `Admin`.`id` LIMIT 10

What version of Phalcon are you using?

edited Jun '15

2.0.x 2.0.3 at this moment