ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

DB Save action - the second table always insert 127

nilubon03 11 Feb, 2014
Hi,

I need to get max cf_id from the first table and change from cf_id to schoolid, then insert the newest schoolid to the second table.

What I did was,
1. I have DB save, save the form data to the first table
2. Create a custom code to get max cf_id and assign max cf_id to schoolid
3. Have a DB save, save the form data to the second table with the newest schoolid

I do not know what did I do wrong, every time, the second DB save always save 127 instead of the max id that I just grab. I have debugger, and I see [chronoforms_data] => array ([Schoolid] =>249. When it inserts, it inserts 127.

My first DB Save
Table = xxxxx_chronoforms_data_school_lookup
Model ID = chronoform_data
Save under Model ID = No
----------------
My custom code
<?php

$db =& JFactory::getDBO();

$db->setQuery('select max(cf_id) from xxxxx_chronoforms_data_school_lookup order by cf_id desc limit 1');

$result = $db->loadResult();

// turn max id to schoolid
$form->data['chronoform_data']['Schoolid'] = $result;

// assign new schoolid to school id in internship table
$form->data['Schoolid'] = $form->data['chronoform_data']['Schoolid'] ;
?>
---------------
My second DB Save
Table = xxxxx_chronoforms_data_internship
Model ID = blank, no Model ID
Save under Model ID = No

Please advise,

Thank you,

Nilubon
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com