i wrote my own mysql funtion, and i want to run it from in side yii. but it keeps telling me:
Active record "Daytrip" is trying to select an invalid column "geodistkm(53.2095685969". Note, the column must exist in the table or be an expression with alias.
public function scopes()
{
return array(
'distance' => array(
'limit' => 10,
'select' => array(new CDbExpression("geodistkm($this->latitude, $this->longitude, rCity.Latitude, rCity.Longitude) AS distance"))
)
);
}
wil give me the following query:
SELECT geodistkm(53.2095685969, 6.56982421875,
rCity.Latitude, rCity.Longitude) AS afstand, `Daytrips`.`IdDaytrip` AS
`t0_c0`, `rCity`.`IdCity` AS `t1_c0`, `rCity`.`CountryId` AS `t1_c1`,
`rCity`.`Province` AS `t1_c2`, `rCity`.`Municipality` AS `t1_c3`,
`rCity`.`City` AS `t1_c4`, `rCity`.`Latitude` AS `t1_c5`,
`rCity`.`Longitude` AS `t1_c6`, `rCity`.`GoogleMatch` AS `t1_c7` FROM
`Daytrips` LEFT OUTER JOIN `Cities` `rCity` ON
(`Daytrips`.`CityId`=`rCity`.`IdCity`) LIMIT 10
now it was giving me the error: Property “Daytrip.distance” is not defined. so i created a public field named $distance in the model but when i print the distance in the view it’s will remain empty…