Hello all!

I´m working in a RIA that uses arp/arpx on the client side and CakePHP (www.cakephp.org) and AMFPHP (www.amfphp.org) (through CakeAMFPHP) on the server side. I´m very happy with the results but there´s something that really bothers me and that I would be very happy if anyone could clear up my mind on this subject.

Sometimes, I find myself doing the following:

[PHP]
    function getAgenda($offset = '0', $limit = '10') {
       
        $this->autoRender = false;
        $this->constructClasses();
       
        //primeiro convertemos a data de hj para Unix Timestamp!
        $hoje = getDate(); //pega a data de hj...
        $hoje_timestamp = mktime(0,0,0,$hoje["mon"],$hoje["yday"],$hoje["year"]);
       
        $this->countQuery = "SELECT COUNT(*) AS recordCount FROM Events WHERE Event.event_date > $hoje_timestamp";
       
       
        $agenda = $this->Event->findAll("event_date > $hoje_timestamp","event_date"," Event.event_date desc",$limit,$page,false);
     
       
       
          $returned_events = Array();
       
       

//In this foreach, I get the array fetched by the findAll() method and I then augment some "properties" from other tables...

        foreach($events as $ev) {
           
            $casa_id = $ev['Event']['casa_id'];
            $ev['Event']['Casa_Name'] = $this->Casa->field("name","id = '$casa_id'");
            $ev['Event']['event_date'] = $this->Event->timetostr($ev['Event']['event_date']);
            $returned_events[] = $ev;
           
               
               
        }
       
        return $returned_events;
       
       
    }
[/PHP]

By using this technique, I save a lot of work and bandwidth as related data is directly fetched in this method. However, I feel this isn´t the best way to do that. Firstly, I can´t use the RecordSet class as I´m returning fetched data and not the mysql resource id, second, I think this kind of thing could be done entirely on the DMBS layer, through SQL. And finally, for CakePHP experts, maybe Cake has a easy way to do such things?

Thanks in advance,

- Marcelo.
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to