Sajid,

Still under a tight deadline atm, but this is what i have working for  
me so far:

To write it to DB:
public function create($obj)
        {
        
                $query = "INSERT INTO Event
                
                (
                DateStart,

                )
                
                VALUES
                
                (
                
'".date("Y-m-d",mysql_real_escape_string($obj["DateStart"])/1000)."'


To read it back out - the query:

public function getOne($id)
        {
                $query = "SELECT
                date_format(DateStart, '%a %b %e %T GMT+1000 %Y') as DateStart,


Which will format the string exactly as new Date() outputs for me  
(couldn't quickly find a way to get the timezone + offset so it's hard  
coded).

Then in my VO which is sent back via amf:

<?php
class EventsVO {
        var $_explicitType="vo.EventsVO";
        public $_DateStart;

        public function EventsVO()
        {
                
        }
        
        public function mapObject($data)
        {
                $this->_DateStart = $data["DateStart"];
        }

}
?>


Take note that I have prepended the VO DateStart field with an  
underscore, the reason for this is apparent in the .as VO below:

package com.aom.mfl.vo
{
        [RemoteClass(alias="vo.EventsVO")]      
        [Bindable]
        public class SEvent
        {

                public var _DateStart:String;


                public function SEvent()
                {
                        
                }

                public function set DateStart(val:Date):void{
                        _DateStart = val.toString();
                }
                
                public function get DateStart():Date{
                        if (_DateStart == null){
                                return new Date();
                        }
                        return new Date(_DateStart);
                }
        }
}

Effectively the remoting will set the string of _DateStart but all  
other code throughout my flex app will refer to DateStart which  
returns the true Date object, you could create another private field  
to hold the Date object instead of parsing the string version on each  
request.

Cheers,
Nik

Reply via email to