Forums

Database Save Question

jhdesign 07 Dec, 2011
I have a single grid form (5 columns, each column has 30 rows).

I'd like to save each column as a separate DB row instead of entire form field data.

Is this possible?
Max_admin 08 Dec, 2011
Hi Jacob,

You can do it with some PHP coding, you will need to trigger a virtual "DB Save" action 5 times in run time to be able to save 5 different data rows, you will need to create a good data array every time for each row (30 fields).

here is the code to trigger the virtual action:


$db_save_details = new stdClass();
$db_save_details->type = 'db_save';
$db_save_Params = new JParameter('');
$db_save_Params->set('table_name', 'table_name_here');
$db_save_Params->set('model_id', 'MYID');
$db_save_Params->set('save_under_modelid', 1);
$db_save_details->params = $db_save_Params->toString();
$form->data['MYID'] = array('f1' => 'v1', 'f2' => 'v2', ...., 'f30' => 'v30');//you need to create this array using a for loop or something
$form->runAction($db_save_details);


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jhdesign 12 Dec, 2011
Thanks Max, above generated some errors. I ended up loading standard Joomla SQL insert query which worked fine.
This topic is locked and no more replies can be posted.