Welcome, Guest
  • Author Topic: retrieve data DB and modifications  (Read 1633 times)

    cyril

    • Jr. Programmer
    • **
    • Posts: 90
      • View Profile
      • T-prod Portfolio
      • Email
    retrieve data DB and modifications
    « on: 07/07/03, 08:57 »
    I wonder how to display what we want when we retrieve data like recorsets.

    1. My objective is for example to display a specific field in my table in a dynamic textfield.
    2. Then, I have also a problem with date in mysql. The format is : 2003-07-09 and I want :
    09-07-2003
    I would like to resolve this problem in actionscript  if it's possible. So can someone help me ??

    :)thanks

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:retrieve data DB and modifications
    « Reply #1 on: 07/07/03, 16:54 »
    You can use different methods to retrieve data form your DB. This is a good resume: http://www.flash-db.com/Board/index.php?board=19;action=display;threadid=3062

    If you want to use Recordset objects, you need to use Flash Remoting components and CFM or amfphp.
    Changing the data format is easy to do in your SQL, but if you want to do in Flash, here's a simple function

    [script]
    function changeDate(date){
      return(date.substr(8, 2)+"-"+date.substr(5, 2)+"-"+date.substr(0, 4))
    }
    trace(changeDate("2003-07-09"));
    [/script]

    Since the date the database returns is a string, you just use string methods

    Jorge

    cyril

    • Jr. Programmer
    • **
    • Posts: 90
      • View Profile
      • T-prod Portfolio
      • Email
    Re:retrieve data DB and modifications
    « Reply #2 on: 07/08/03, 03:39 »
    Your solution is better than mine :  ;D

    Code: [Select]
     
    var a = date.charAt(4);
    var b = date.charAt(7);
       if(a=="-" and b=="-"){
          var annee = date.slice( 0, 4 );
          var mois = date.slice( 5, 7 );
          var jour = date.slice( 8, date.length);
          date = jour+"-"+mois+"-"+annee;
                   }


    But now I've modified all dates how can I display all the table plus records with modifications ?

    For the moment I use a script like that in a "Onresult" method :
    Code: [Select]


    if(pData){
       for (var i=0; i<pData.getLength(); i++) {
                   
                            for (var z in pData.getItemAt(i)) {

                                //---->>>>>How recognize a date ???
                                //---->>>>>How apply changes occured and display dates???
                     txtactu.htmlText += pData.getItemAt(i)[z];
                }
       }
    } else {
        txtactu.htmlText = "Aucune Actualité";
    }
     



    In fact I have a table (actu) with 3 fields :

    <numactu>
    <libactu>
    <dateactu>

    I would like to do a sort of news rubric

    Ex:
    -----------------------------------------------------------------
    08/07/2003

    Flash-DB has overpassed the million of registered !!

    -----------------------------------------------------------------
    07/07/2003

    Flash-DB is the best forum for flash remoting !!

    -----------------------------------------------------------------
    ...
    ....

    Can you help me ???

    I looked the post you gave me and why including amfphp.php in server part ???

    Sorry, I can do lot of mistakes I'm French  ;)

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:retrieve data DB and modifications
    « Reply #3 on: 07/08/03, 09:37 »
    You can look for certain row using the colum name, in example:

    myDate = result.getItemAt(0).Date //The column name is Date

    Check Recordset methods in the Flash Remoting ActionScript Dictionary

    If you're using Coldfusion, then there's no need for amfphp.
    amfphp is a free alternative to CFM, see http://www.amfphp.org with similar functionalities. If you're interested, you can see also Hello World Remoting

    Jorge