Decode and encode
Username:  
Password:
  > Home
v User Guide
    > Introduction
    > Hello World
    > Flow Control
    > Function Calls
    > Authentication
    v Database access
       o Decode and encode
       o Searching
       o Display paging
       > Modify records
    > Content Management
    > Remote Calling
    > Object-Oriented
    > Other Features
> Reference
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> User Guide >> Database access >> Decode and encode <=  =>      <  1  >  
Decode and encode

Hang on!  What is the number in the Birthday column?  Can we format it with something like ${rec:Birthday|strftime:%d/%m/%Y}?  Yes, you can do that.  There is also an alternative way:

var phbook%decode:Birthday = "strftime:%d/%m/%Y";

 

And this needs to be done before the retrieval loop starts.  In fact, you can change it on the fly and all subsequent record retrieval will use the new Conversion specification in the new "decode" variable.  Now we have:

ID Name       Tel      Height Birthday

16 Joe Chan   98765432 178    22/03/2001

17 Dick Smith 87654321 147   

 

Decoding automatically upon retrieval (the phbook%decode way) is implemented in the lower level BEE database engine and therefore is more general and powerful.  Together with the "encode" variable, you can conceal the true value of the field entirely.

For example, if you allow update of the Birthday field in the above example, instead of updating with the value in timestamp format, you can update it directly with the date string.  All you need to do is to define this:

var phbook%encode:Birthday = "strtotime";

 

When the Birthday field is inserted or updated, the date string (e.g. 26/12/1981) will be automatically converted to the timestamp format, as specified in the "encode" variable, before saving into the database.  When the Birthday field is retrieved, it will be automatically converted to the date string format, as specified in the "decode" variable, before being made available to the script context.  How the date is being implemented at the database level is transparent, once the "decode" and "encode" variable is defined for the field.

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd