Best way to retrieve/store date Flex PHP MySQL?

Hi All,
I have a question about storing/retrieving a date-field from the MySQL database, using Flash Builder 2 & Zend AMF.
This is as much as I know:
MySQL Database stores date in this format: yyyy-mm-dd hh:mm:ss
And Flex will not recognise that as a "date", instead it will suggest this value is an "object".
With "Configure return type", I can manually set this field to "date", but it will not work retrieving of updating the date as MySQL will not understand the standard date-format it'll receive,
I guess, the best solution would be if I could tell the MySQL Server how the standard date-format should be, but I have not found this option. Can anyone confirm this?
The remaining options are:
Format the date in the SQL-query
Format the date in the PHP-function sending/retrieving
Format the date in Flex, befor assigning it to a date-field...
Can someone tell me the BEST practice to handle date-objects? I guess it's the date_format function in MySQL....
I'm trying to build an app with over 3200 fields, shared over 60 tables, of which many are date-fields.
Would be awesome if I could just use SELECT * FROM myTable, and all would be fine with date-fields and all...
Any tips?

I'm confused. This is what I have:
On my MySQL database, I've created a VIEW with the query that I need. I thought it'd generally be efficient to create views for every 'Form' that I need.
This is my VIEW v_person
SELECT p.`person_id`, p.`name`, p.`lastname`, DATE_FORMAT(p.`birthdate`,'%d/%m/%Y %r') as birthdate
FROM person p
Now I have a simple table v_person returning
person_id
name
lastname
birthdate
0
John
Doe
null
1
Jane
Did
23/08/1976 12:00:00 AM
2
Juno
Doh
01/04/2001 12:00:00 AM
"Great! Now I can set up my query once, returning the date in whatever format Flex likes."
Not.
This is the standard generated PHP function to get information by ID. This works fine.
     public function getV_personByID($itemID) {
          $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where person_id=?");
          $this->throwExceptionOnError();
          mysqli_bind_param($stmt, 'i', $itemID);          
          $this->throwExceptionOnError();
          mysqli_stmt_execute($stmt);
          $this->throwExceptionOnError();
          mysqli_stmt_bind_result($stmt, $row->person_id, $row->name, $row->lastname, $row->birthdate);
          if(mysqli_stmt_fetch($stmt)) {
               return $row;
          } else {
               return null;
This is the standard generated Form in Flex:
One note to make when using RETURN TYPE,
is that in when I use person_id=0 , I can change "birthdate type" from OBJECT to DATE, because date is null.
When I use person_id=1 , I CAN'T change "birthdate type" as it defaults to "STRING".
Since I want to use a dateField in my Form, I changed birthdate type to "DATE". (Even though I now understand that return type IS in fact a string)
<fx:Script>
     <![CDATA[
          import mx.controls.Alert;
          import mx.formatters.DateFormatter;
               protected function button_clickHandler(event:MouseEvent):void
               getV_persontestByIDResult.token = vpersontestService.getV_persontestByID(parseInt(itemIDTextInput.text));
     ]]>
</fx:Script>
<fx:Declarations>
          <vpersontestservice:VpersontestService id="vpersontestService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
     <s:CallResponder id="getV_persontestByIDResult" result="v_persontest = getV_persontestByIDResult.lastResult as V_persontest"/>
     <valueObjects:V_persontest id="v_persontest" person_id="{parseInt(person_idTextInput.text)}" />
     <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:Form defaultButton="{button}">
     <mx:FormItem label="ItemID">
          <s:TextInput id="itemIDTextInput"/>
     </mx:FormItem>
     <s:Button label="GetV_persontestByID" id="button" click="button_clickHandler(event)"/>
</mx:Form>
<mx:Form>
     <mx:FormHeading label="V_persontest"/>
     <mx:FormItem label="Birtdate">
          <mx:DateField id="birthdateDateField" selectedDate="@{v_persontest.birthdate}" />
     </mx:FormItem>
     <mx:FormItem label="Last name">
          <s:TextInput id="lastnameTextInput" text="@{v_persontest.lastname}"/>
     </mx:FormItem>
     <mx:FormItem label="First name">
          <s:TextInput id="nameTextInput" text="@{v_persontest.name}"/>
     </mx:FormItem>
     <mx:FormItem label="person_id">
          <s:TextInput id="person_idTextInput" text="{v_persontest.person_id}"/>
     </mx:FormItem>
</mx:Form>
Works great! Except that it can't handle the date field:
TypeError: Error #1034: Type Coercion failed: cannot convert "10/21/1984 12:00:00 AM" to Date.
     at com.adobe.serializers.utility::TypeUtility$/assignProperty()[C:\perforceGAURAVP01\depot\flex\ide_builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\utility\TypeUtility.as:534]
     at com.adobe.serializers.utility::TypeUtility$/convertToStrongType()[C:\perforceGAURAVP01\depot\flex\ide_builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\utility\TypeUtility.as:497]
     at com.adobe.serializers.utility::TypeUtility$/convertResultHandler()[C:\perforceGAURAVP01\depot\flex\ide_builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\utility\TypeUtility.as:371]
     at mx.rpc.remoting::Operation/http://www.adobe.com/2006/flex/mx/internal::processResult()[E:\dev\trunk\frameworks\projects\rpc\src\mx\rpc\remoting\Operation.as:316]
     at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\trunk\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:313]
     at mx.rpc::Responder/result()[E:\dev\trunk\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
     at mx.rpc::AsyncRequest/acknowledge()[E:\dev\trunk\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
     at NetConnectionMessageResponder/resultHandler()[E:\dev\trunk\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:547]
     at mx.messaging::MessageResponder/result()[E:\dev\trunk\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:235]
Somehow SOMETHING wants to convert "10/21/1984 12:00:00 AM" to Date.
Where does it fail? I feel like I'm SO close, but making a faceplant right before the finish.
ok.
I'm by no means an expert, so let me know if I'm doing something wrong, but this is how I'd expect it to work.
Can someone tell me how I should use a dateField instead? Where should I make the stringToDate and dateToString conversion?

Similar Messages

  • I allowed ATT store to re set my iphone 4 and need to know if there might be a way to retrieve the data

    I allowed ATT store to re set my iphone 4 and need to know if there might be a way to retrieve the data?

    Resetting should not have deleted your data. 
    But if you backed your phone up to iTunes or iCloud you should be able to restore it from there.
    http://support.apple.com/kb/HT1414

  • Best way to retrieve data for jsp

    Hi,
    I'm fairly new to java and am preparing to create some jsp's for our intranet. The pages need to include data from a db2 database. I know pretty much what I need to do, but I'm trying to decide the best(most efficient) way to retrieve the data to display. I've looked at a number of examples and the more I look, the more confused I get (it would be so easy on the AS400 which is my background so you can see how new this is to me). I see my options as: using an 'include' statement to include another java file that retrieves the data; or use a java bean; or just instantiate an instance of the class and 'call' the methods for that class directly; or lastly, place all the code directly in the jsp to connect to the database and query the table.
    What's the real difference between these options and what's usually the most efficient and preferred way?
    Thanks for any advice and clarification.

    As a general rule, it's a good idea to separate the
    presentation (JSP and HTML) from the business rules
    (database access). I know you didn't do that on the
    AS/400, you had display files and business logic in
    the same program (at least, we certainly do in ours),
    but it's a good policy to follow in the web world.
    That means, don't put your database access code in
    the JSP. Other than that, it depends on the data.
    If you have simple data (e.g. customer's name and
    d address) then a Java bean would suffice. If you
    have complex data (e.g. customer's payment history)
    then a bean still might suffice. You would use an
    "include" if you had some data (static or dynamic)
    that you wanted to appear in several different pages
    in the same form.Thanks, I figured putting the code in the JSP was not the best way, but I wasn't sure about the other options.

  • I am moving from PC to Mac.  My PC has two internal drives and I have a 3Tb external.  What is best way to move the data from the internal drives to Mac and the best way to make the external drive read write without losing data

    I am moving from PC to Mac.  My PC has two internal drives and I have a 3Tb external.  What is best way to move the data from the internal drives to Mac and the best way to make the external drive read write without losing data

    Paragon even has non-destriuctive conversion utility if you do want to change drive.
    Hard to imagine using 3TB that isn't NTFS. Mac uses GPT for default partition type as well as HFS+
    www.paragon-software.com
    Some general Apple Help www.apple.com/support/
    Also,
    Mac OS X Help
    http://www.apple.com/support/macbasics/
    Isolating Issues in Mac OS
    http://support.apple.com/kb/TS1388
    https://www.apple.com/support/osx/
    https://www.apple.com/support/quickassist/
    http://www.apple.com/support/mac101/help/
    http://www.apple.com/support/mac101/tour/
    Get Help with your Product
    http://docs.info.apple.com/article.html?artnum=304725
    Apple Mac App Store
    https://discussions.apple.com/community/mac_app_store/using_mac_apple_store
    How to Buy Mac OS X Mountain Lion/Lion
    http://www.apple.com/osx/how-to-upgrade/
    TimeMachine 101
    https://support.apple.com/kb/HT1427
    http://www.apple.com/support/timemachine
    Mac OS X Community
    https://discussions.apple.com/community/mac_os

  • Best way to "page" through data?

    If I have a XM, something like
    <people>
    <person>
    <firstname>john</firstname>
    <lastname>smith</lastname>
    </person>
    <person>
    <firstname>robert</firstname>
    <lastname>walker</lastname>
    </person>
    </people>
    And I create some bound fields to display this, what's the best way to "page" the data?
    I know I can create an XML variable of the data and then access person[0].firstname, but I need to have a button or other ui element that would choose person 0,1,2,3 etc.
    Normally I's use a list, but this application calls for a static screen where only the data changes when buttons are chosen.

    I use this method(this is simplified) as it doesn't require any sort of data services, you can have change events etc for editing/deleteing. the slider is just for poc, a prev/next button could just as easily do.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="800" minHeight="400" creationComplete="initApp()" width="800" height="400">
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    [Bindable] private var Arr:ArrayCollection=new ArrayCollection();
    private var Sel:int = 0;
    protected function initApp(): void
    Arr.addItem({id:1,name:"John",surname:"Robertson",age:30});
    Arr.addItem({id:2,name:"Peter",surname:"Williams",age:35});
    Arr.addItem({id:3,name:"Jane",surname:"Brown",age:23});
    Arr.addItem({id:4,name:"Rebecca",surname:"Smith",age:42});
    Arr.addItem({id:5,name:"Susan",surname:"Reynolds",age:25});
    Arr.addItem({id:6,name:"Michael",surname:"Royce",age:23});
    Arr.addItem({id:7,name:"Jack",surname:"Jones",age:22});
    Arr.addItem({id:8,name:"Pete",surname:"Young",age:50});
    Arr.addItem({id:9,name:"Robert",surname:"Peters",age:39});
    hs.maximum = Arr.length-1;
    hs.value = 0;
    updateList();
    protected function updateList():void
    Sel = hs.value;
    surname.text= Arr[Sel].surname;
    firstname.text= Arr[Sel].name;
    age.text= Arr[Sel].age;
    ]]>
    </fx:Script>
    <s:Group width="497" height="114" horizontalCenter="0" verticalCenter="0">
    <s:TextInput id="surname" x="46" y="45"/>
    <s:TextInput id="firstname" x="182" y="45"/>
    <s:TextInput id="age" x="318" y="45"/>
    <s:HSlider id="hs" x="62" y="96" width="200" minimum="0" maximum="1" liveDragging="true" change="updateList()" value="-1"/>
      </s:Group>
    </s:Application>
    David

  • Is there a simple way to retrieve the data from a resultset using JavaBean?

    I have a result set from a select * from users where userid = xxx statement. However, at the moment I have had to hard code the remainder of the code to get the data from each column as I need the column name as well as its data.
    I had read somewhere using java beans and reflection it is easier. But i do not know know how.
    Is there a simple way to retrieve the data from a result set ?
    thanks in advance-
    kg

    Well, it is not really simple. But there are Open Source components to simplify it for you. See e.g http://www.must.de/Jacompe.htm - de.must.dataobj.DataObject and its subclasses. Feel free to contact me if you have any questions: [email protected]

  • What is the best way to mimic the data from production to other server?

    Hi,
    here we user streams and advanced replication to send the data for 90% of tables from production to another production database server. if one goes down can use another one. is there any other best option rather using the streams and replication? we are having lot of problems with streams these days they keep break and get calls.
    I heard about data guard but dont know what is use of it? please advice the best way to replicate the data.
    Thanks a lot.....

    RAC, Data Guard. The first one is active-active, that is, you have two or more nodes accessing the same database on shared storage and you get both HA and load balancing. The second is active-passive (unless you're on 11.2 with Active Standby or Snapshot Standby), that is one database is primary and the other is standby, which you normally cannot query or modify, but to which you can quickly switch in case primary fails. There's also Logical Standby - it's based on Streams and generally looks like what you seem to be using now (sort of.) But it definitely has issues. You can also take a look at GoldenGate or SharePlex.

  • Best Way to port the data from one DB to another DB using Biztalk

    Hi,
    please suggest best way to move the data from one db to another DB using biztalk.
    Currently I am doing like that, for each transaction(getting from different source tables) through receive port, and do some mapping (some custom logic for data mapping), then insert to target normalized tables(multiple tables) and back to update the status
    of transaction in source table in sourceDB. It is processing one by one.
    How/best we we can do it using  bulk transfer and update the status. Since it has more than 10000 transaction per call.
    Thanks,
    Vinoth

    Hi Vinoth,
    For SQL Bulk inserts you can always use SQL Bulk Load
    adapter.
    http://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalksyn/archive/2005/10/23/processing-a-large-flat-file-message-with-biztalk-and-the-sqlbulkinsert-adapter.aspx
    However, even though a SQL Bulk Load adapter can efficiently insert a large amount of data into SQL you are still stuck with the issues of transmitting the
    MessageBox database and the memory issues of dealing with really large messages.
    I would personally suggest you to use SSIS, as you have mentioned that records have to be processed in specific time of day as opposed to when the
    records are available.
    Please refer to this link to get more information about SSIS: http://msdn.microsoft.com/en-us/library/ms141026.aspx
    If you have any more questions related to SSIS, please ask it in
    SSIS 
    forum and you will get specific support.
    Rachit

  • What is the best way to export the data out of BW into a flat file on the S

    Hi All,
    We are BW 7.01 (EHP 1, Service Pack Level 7).
    As part of our BW project scope for our current release, we will be developing certain reports in BW, and for certain reports, the existing legacy reporting system based out of MS Access and the old version of Business Objects Release 2 would be used, with the needed data supplied from the BW system.
    What is the best way to export the data out of BW into a flat file on the Server on regular intervals using a process chain?
    Thanks in advance,
    - Shashi

    Hello Shashi,
    some comments:
    1) An "open hub license" is required for all processes that extract data from BW to a non-SAP system (including APD). Please check with your SAP Account Executive for details.
    2) The limitation of 16 key fields is only valid when using open hub for extracting to a DB table. There's no such limitation when writing files.
    3) Open hub is the recommended solution since it's the easiest to implement, no programming is required, and you don't have to worry much about scaling with higher data volumes (APD and CRM BAPI are quite different in all of these aspects).
    For completeness, here's the most recent documentation which also lists other options:
    http://help.sap.com/saphelp_nw73/helpdata/en/0a/0212b4335542a5ae2ecf9a51fbfc96/frameset.htm
    Regards,
    Marc
    SAP Customer Solution Adoption (CSA)

  • I am giving away a computer, what is the best way to wipe out data prior to depature

    i am giving away a computer, what is the best way to wipe out data prior to depature

    Did the Mac come with two grey disks when new? If so, use disk one to erase the drive using Disk Utility and then re-install the OS from the same disk. Once installed, quit and when the new owner boots they can set it up as a new out-of-the-box Mac when they boot it up. The grey disks need to be passed on with the computer.
    If you need detailed instructions on how to erase and re-install please post back.
    If the Mac came with Lion or Mountain Lion installed the above process can be done using the Recovery HD as since Lion no restore disks are supplied with the Mac.
    The terms of the licence state that a Mac should be sold/passed on with the OS installed that was on the machine when new (or words to that effect).

  • Best way to accept a date from a user

    Hi Guys,
    Whats the best way to get a date from a user and add it in an
    insert record to access.
    I have a form that adds a record and it works well enough as
    long as the data added is in the correct format.
    Untill now ive just had a text box with an explination to the
    user on how to add the date and what format....
    But Im fed up with having to change bad entrys and need to
    place a control or something on the form but dont know whats
    easiest and best?
    Any ideas welcome.
    Thanks

    If you want today's date set the database up to insert the
    date
    automatically. If you want other dates than today's use a
    date picker or
    calendar to insert the date.
    Dave
    "Tag2007" <[email protected]> wrote in
    message
    news:epj87p$mar$[email protected]..
    > Hi Guys,
    >
    > Whats the best way to get a date from a user and add it
    in an insert
    record to
    > access.
    >
    > I have a form that adds a record and it works well
    enough as long as the
    data
    > added is in the correct format.
    >
    > Untill now ive just had a text box with an explination
    to the user on how
    to
    > add the date and what format....
    >
    > But Im fed up with having to change bad entrys and need
    to place a
    control or
    > something on the form but dont know whats easiest and
    best?
    >
    > Any ideas welcome.
    > Thanks
    >

  • What is the best way to edit meta data..

    What is the best way to edit meta data and tag photos, faces, places etc. and have the data saved to the original photo.
    On a PC I would just use Windows Gallery. iPhoto on the Mac allows for some tagging, but it doesn't save to the original file.
    I like to have my photos in a folder, edit them and save the changes.
    What software would work best on a MAC to accomplish this?
    Thanks for any help,
    Nick

    iPhoto is a database and any metadata you add or edit is available in any app - if you learn how to use it.
    iPhoto is a non-destructive processor. It never touches the original file - it treats it like a film shooter treats the negative.
    If you want a copy of the original file with the metadata included simply export a copy.
    This User Tip
    https://discussions.apple.com/docs/DOC-4921
    has details of the options in the Export dialogue.
    As an FYI:
    For help accessing your photos in iPhoto see this user tip:
    https://discussions.apple.com/docs/DOC-4491

  • Best way to edit/update data in JSP ?

    Hi Friends,
    I want to know about Update / Edit data procedure in JSP.
    ie.
    If we have one form having 10 fields, and we need to change only
    1 field then do we require to set update query for all 10 fields ?
    don't it make some overload ?
    Can you give me solution like that ?
    and I want to update data like we use CakePHP scaffold functionality.
    data from database is displayed in field and we just need to edit data
    and save it.
    Can we have such in JSP ? see I don't know struts or any frameworks
    Better you will suggest way to do in JSP.
    for Insert I use Bean [ one java class get the parameters for all fields and query ]
    Please suggest me to set the value to field on edit / update
    and best way to update the data.
    -GkR

    It's easy if you want upade game files, not game engine binary.
    You can make your app that will load swf file. So you can make engine that will load all files externaly from device. Firstly you run app and if it connected by wifi - ask user for upadate wish and that simply download from http files as binary and save they using FileSystem

  • Best way to check the data

    I have a made some changes to an existing view. The change is adding a join and a new column from new table. I have created a version2 with all these changes. I want to make sure that same data exists in both the views. what is the best way to test the data.

    Bad wording, the query results could be:
    No rows selected. Same number of rows on both views and same data (considering view1 structure and view without the new column)
    At least one row selected. If the count(*) on both was different, rows returned will be at least the difference. If the count was the same, then every returned row means that there's no equivalent row on view2 and a data difference may exist in at least one of the fields, so You have to find the equivalent row on view2 to compare.
    On the query sintaxis, as view2 hava a new column and I guess it's not a constant value, You have to specify every column for the view1, and the same columns for view2, so new field isn't included and compared.

  • Best way to extract XML data to DB

    Hello,
    In our work we need to extract data from XML documents into a database. Here are some extra notes:
    + There is no constant schema for the XML documents.
    + Some processing on the XML files is required.
    + The XML documents are very big.
    + The database is Oracle 8i or 9i (Enterprise Edition both) and our framework is NET.
    Our questions are:
    1. What is the best way to extract the data into the database under the above circumstances ?
    2. In case there was a constant schema for the XML documents, would there be a better way ?
    3. Is writing the data to text files first, and then loading it via SQL-Loader is an effective way ?
    Any thoughts would be welcome. Thanks.

    Hi Nicolas,
    The answer depends on your actual storage method (binary, OR, CLOB?), and db version.
    You can try XMLTable, it might be better in this case :
    SELECT x.elem1, x.elem2, ... , x.elem20
    FROM your_table t
       , XMLTable(
          '/an/xpath/to/extract'
          passing t.myxmltype
          columns elem1  varchar2(30) path 'elem1'
                , elem2  varchar2(30) path 'elem2'
                , elem20 varchar2(30) path 'elem20'
         ) x
    ;

Maybe you are looking for