[eluser]cberk[/eluser]
Is there a way with DMZ to include calculated fields in the object when writing a custom sql query? Basically, I would just like it to trust me and pick up all the fields in the table result and allow me to access them through the object.
I've noticed that custom fields are included if my query returns one row, and I reference the original object, but what I need is the ability to access these fields when I loop through the $object->all array.
Here's a code example:
Code:
$m = new Metro();
$m_sql = "SELECT `normal_metros`.*, COUNT(`join_listings_metros`.`metro_id`) as `num_listings`
FROM `normal_metros`
etc, etc, etc................
GROUP BY `normal_metros`.`id`";
$m->query($m_sql);
foreach ($m->all as $metro)
{
echo $metro->num_listings; // This value isn't stored in the object, even though it was created in the query.
}