[FX.php List] Generating Safe links to Database Records

Steven Thoms sthoms at wavecomm.com
Tue Jan 17 06:58:16 MST 2012


Malcolm,

I use this to make the result['data'] array more useable:

function simplifyData($data) {
     $newArray = array();
     $i=0;
     foreach( $data as $key=>$fieldArray ) {
         $FMPids = explode(".",$key);
         $newArray[$i]['recid'] = $FMPids[0];
         $newArray[$i]['modid'] = $FMPids[1];
         foreach( $fieldArray as $field=>$value ) {
             if ( is_array ( $value ) && isset ( $value[0] ) ) {
                 if ( substr($value[0], 0, 3) == '*!*' )
                     $newArray[$i][$field] = substr($value[0], 3);
                 else
                     $newArray[$i][$field] = nl2br($value[0]);
             } else {
                 $newArray[$i][$field] = '';
             }
         }
     $i++;
     }
     /* i.e. Array
     (
         [0] => Array
             (
                 [recid] => 3
                 [modid] => 575
                 [account_active] => 1
                 [account_name] => sthoms
                 [account_pass] => password
                 [full_name_c] => Steve Thoms
                 [security_level] => 1
             )

     )
     */
     return $newArray;
}

Steve
207 798-0171

On Jan 16, 2012, at 7:18 PM, Malcolm Fitzgerald wrote:

>
> On 17/01/2012, at 11:02 AM, Malcolm Fitzgerald wrote:
>
>> This morning I was testing a routine and the results looked odd.  
>> After some head-scratching I increased the modification number on  
>> the record and got the right results. The record id returned by FX  
>> consists of the internal record ID and it's modification number.  
>> The modification number is inherently unstable.
>>
>> I want to be able to generate links to records in the database that  
>> do not rely on the modification number. How does FX handle this?
>
> I'll answer my own question.
>
> Searching by -recid works perfectly well as the key to access data  
> but it is not sufficient to act as a key for the data array which is  
> returned. The returned array has a key which consists of the  
> internal record ID and it's modification number. There should only  
> be one item returned array so it is easy to access.
>
> Malcolm_______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>



More information about the FX.php_List mailing list