• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: SQL not working in RSForm Pro

SQL not working in RSForm Pro 6 months 1 week ago #43044

  • Roberts
  • Roberts's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 54
  • Thank you received: 1
Following the instruction for...

www.rsjoomla.com/support/documentation/r...st-from-a-table.html

I'm having trouble returning an average for a field. The query works fine in MySQL and returns the correct average but when I apply the same SQL into the Default Value of a text box, it returns an empty box.

Default Value SQL is as follows...
$db->setQuery("SELECT ROUND(AVG(FieldValue),2) FROM `jos_rsform_submission_values` WHERE `FormId` = 27 AND `FieldName` LIKE 'sys' ORDER BY `jos_rsform_submission_values`.`FieldValue` DESC LIMIT 1");

Any help greatly appreciated.
The administrator has disabled public write access.

SQL not working in RSForm Pro 6 months 1 week ago #43045

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 216
  • Thank you received: 57
I've never done this directly in the field, I use the 'PHP scripts - pre processing' using joomla docs here

Scrolling down will show how to get a single value result using
$db = JFactory::getDbo();
$query = $db
    ->getQuery(true)
    ->select('COUNT(*)')
    ->from($db->quoteName('#__my_table'))
    ->where($db->quoteName('name') . " = " . $db->quote($value));
 
// Reset the query using our newly populated query object.
$db->setQuery($query);
$count = $db->loadResult();

Obvioulsy modify it to fit your query then (if I'm right) you just assign the $count variable to your field with
$val['your-field-name'] = $count;
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!