Forums

DB Viewer

Huski 05 Mar, 2015
Can;t quite work out how the DBViewer in V5 works - compared to V4. I can't work out how to display the data I want from a table.

Can't find any documentation with search.
GreyHead 05 Mar, 2015
Hi Huski,

Add the colums + titles you want displayed in the Data Viewer tab in the Form Editor - I think that is what you need.

Bob
Huski 09 Mar, 2015
Thanks Bob - worked it out. It's a lot more tedious than version 4.

What I am also finding is that the fields - cf_Uid, cf_created, cf_modified, cf_ipaddress, cf_user_id which are being captured in the Version 4 form are not being added to the database table in Version 5. Is there somewhere I need to go to activate this?
GreyHead 09 Mar, 2015
Hi Huski,

For reasons unknown to me Max changed the column naming in CFv5. Here's how they link up CFv4 -> CFv5
cf_id -> id (the primary key column)
cf_uid -> uniq_id
cf_created -> created
cf_modified -> modified
cf_ipaddress ->  (no longer added automatically)
cf_created_by ->  (no longer added automatically)
cf_modified_by ->  (no longer added automatically)
cf_user_id -> user_id

I think that you can either have the values added automatically by changing the column names in the table; or use the old table names and set values for them using a Custom Code action before the DB Save action.

Bob
Huski 10 Mar, 2015
That did it, changed the database table names and now unique ID and created date works fine. IP address as you mention doesn't although in the email response I get back when the form is completed has the IP address in there. I copied this across from V4 so it must still work when including it in the email.

All good - thanks.
GreyHead 10 Mar, 2015
Hi Huski,

The IP address is added to the $form->data array when an Email action runs, you can pick it up after that; or add your own code to get the IP address in a Custom Code action if you prefer. Here's an example I used recently:
<?php
$form->data['ip_address'] = getIp();

function getIp() {
  $headers = array(
    'HTTP_VIA',
    'HTTP_X_FORWARDED_FOR',
    'HTTP_FORWARDED_FOR',
    'HTTP_X_FORWARDED',
    'HTTP_FORWARDED',
    'HTTP_CLIENT_IP',
    'HTTP_FORWARDED_FOR_IP',
    'VIA',
    'X_FORWARDED_FOR',
    'FORWARDED_FOR',
    'X_FORWARDED',
    'FORWARDED',
    'CLIENT_IP',
    'FORWARDED_FOR_IP',
    'HTTP_PROXY_CONNECTION',
    'REMOTE_ADDR'
  );

  foreach( $headers as $h ) {
    if ( isset($_SERVER[$h]) ) {
      return $_SERVER[$h];
    }
  }
  return '';
}
?>

Bob
Huski 10 Mar, 2015
thanks will try that out
This topic is locked and no more replies can be posted.