Forums

DB Record Loader in Chronoforms5 Using multiple Parameters

atanunu 11 Jul, 2015
I am trying to implement a way via which I could load database record using 5 parameters from an external database
Student ID
School Code
Examination Type
Examination Year
and number of times the user has checked the record (my maximum is 3)

I have read the how to "https://www.chronoengine.com/faqs/70-cfv5/5219-how-to-load-record-data-from-a-database-table-into-your-form.html" and have tried the codes below but I have some problem yet.


<?php 
return array('RCstudentid' => $form->data('RCstudentid'), 'RCschoolcode' => $form->data('RCschoolcode'), 'RCexamtype' => $form->data('RCexamtype'), 'RCexamyear' => $form->data('RCexamyear')); 
?>



return array(
    'RCstudentid' => $form->data('RCstudentid'),
	'RCschoolcode' => $form->data('RCschoolcode'),
    'RCexamtype' => $form->data('RCexamtype'),
    'RCexamyear' => $form->data('RCexamyear'),
	'RCexamyear' != 3,
);
?>


How should I proceed? Please help me out as quickly as possible.

Thank you.
GreyHead 11 Jul, 2015
Hi Atanunu,

Please see this FAQ for more examples. The last line of your query needs to be a little different, and the $form->data[''] entries use square brackets. Please try:
return array(
  'RCstudentid' => $form->data['RCstudentid'],
  'RCschoolcode' => $form->data['RCschoolcode'],
  'RCexamtype' => $form->data['RCexamtype'],
  'RCexamyear' => $form->data['RCexamyear'],
  'RCexamyear != ' => 3
);
?>

Bob
atanunu 11 Jul, 2015
Hello sir,

I am done as explained I replaced the previous code with the new one; but I get a "no record found" response.

I have attached screen shots of the action.

I have read the how to "FAQ" and have tried but I have some problem yet.
GreyHead 11 Jul, 2015
Hi atanunu,

Do you need the External database settings. If the table in in the Joomla! database then you don't, just select the table in the drop-down.

Bob
atanunu 11 Jul, 2015
Hello sir,

I am loading data from an external mysql database. Is it possible to get data from external Microsoft SQL server too?

If I use just one value on the condition box I get results but when I attempt multiple values it turns no data was found.


<?php 
return array('RCstudentid' => $form->data['RCstudentid']); 
?>


<?php 
return array(
  'RCstudentid' => $form->data['RCstudentid'],
  'RCschoolcode' => $form->data['RCschoolcode'],
  'RCexamtype' => $form->data['RCexamtype'],
  'RCexamyear' => $form->data['RCexamyear'],
  'RCexamyear != ' => 3
);
?>
GreyHead 12 Jul, 2015
Hi atanunu,

Please add a Debugger action after the DB Read action - that should show the query that is being generated.

You'd have to test a MSSQL query - sometimes they work but the SQL that ChronoForms generates is not always valid MSSQL :-(

Bob
atanunu 12 Jul, 2015
Hello sir,

here is the outcome of the debug action
GreyHead 12 Jul, 2015
Hi atanunu,

That looks like a valid MySQL query - what happens if you test it in PHPMyAdmin?

Bob
atanunu 14 Jul, 2015
Thanks Sir,

I tried in Phpmyadmin and saw it works well as you corrected. There was an error in my custom code which converted posted data into form data.


<?php 
return array(
  'RCstudentid' => $form->data['RCstudentid'],
  'RCschoolcode' => $form->data['RCschoolcode'],
  'RCexamtype' => $form->data['RCexamtype'],
  'RCexamyear' => $form->data['RCexamyear'],
  'RCusage <= ' => 3
);
?>


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