Forums

CFV5 - Assign Variable To 'DBread' [ModelID][Fieldname]

paulzero 23 Aug, 2016
Hi Bob !

I have got CFV5 working well (Thank you) - but have a new question:

I've set up a CFV5 with 3 different 'DBreads' in 'Form > Setup > On Load'. In 'DBread #2' I'm trying to get DB table field data by using a [Model ID][Fieldname] value generated by 'DBread' #1' - like this :

'DBread #1' > Edit > Model ID = bookings > Conditions =
<?php return array('id' => $form->data['gcb']); ?>

In 'Form > Code' result displayed by table using :
<table><?php foreach ( $form->data['booking'] as $p ) {
  echo "<tr>
  <td>Plan ID</td>
  <td>{$p['name']}</td>
 </tr>";} ?></table>

In Frontend returns :
Plan ID	213

It is the '213' value I need to re-use in 'DBread #2 - Tried like this :

'DBread #2' > Edit > Model ID = fieldvalue > Conditions =
<?php return array('subscriber_id' => $form->data['booking']['name']); ?>

In 'Form > Code' result should display in a table using :
<table><?php foreach ( $form->data['fieldvalue'] as $p ) {
  echo "<tr>
  <td>Values</td>
  <td>{$p['field_value']}</td>
 </tr>";} ?></table>

In Frontend returns : The big nothing !!

Am I going about this the right way ? Or should I use some php to assign the value of ['booking']['name'] ('213') to a variable ?

Cheers - Paul Zero
GreyHead 23 Aug, 2016
Hi PaulZero,

A bit hard to make out but it looks as if your first DB Read is returning an array so the value might be in $form->data['booking'][0]['name'] ???

You can add a Debugger action or two at different points to see exactly what data you have.

Bob
paulzero 24 Aug, 2016
Hi Bob,

Your solution worked first time ! Thanks again mate ! More coffee on route !

Cheers - Paul Zero
This topic is locked and no more replies can be posted.