• 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: FieldName as Columns in query

FieldName as Columns in query 8 years 9 months ago #35438

  • glsarto
  • glsarto's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hi there, here is my problem.
i have some rsform_submissions_values with countrycode as FieldName and its own FieldValue and with city as FieldName and its own FieldValue ON THE SAME SubmissionId
Now i would like to select all the cities with a certain country code FieldValue ( which is another entry in the table tied with the SubmissionId ).
I cant figure out how to make a proper select in this sense.

I made a multidimensional array to link these elements but it doesn't seem to be the efficient way to extract data ( i have almost 50.000 entries in rsform_submission_values )

here is my bad way :
//<code>
$provincia = JRequest::getVar('provincia');
$items = array();
$db = JFactory::getDbo();
$db->setQuery("
SELECT s. * , v . * FROM ii9u2_rsform_submissions s LEFT JOIN ii9u2_rsform_submission_values v ON ( v.SubmissionId = s.SubmissionId ) 
WHERE s.FormId =1 
AND 
v.FormId =1
ORDER BY v.FieldValue ASC
");
$fields = $db->loadObjectList();
$items[] = '|';
 
foreach ($fields as $field){
	$submission->values[$field->SubmissionId][$field->FieldName] = $field->FieldValue;
}
$citta = array();
foreach ($submission->values as &$value) {
    foreach ($value as &$FieldName){
		if($value['district_short'] == $provincia){
			if (!in_array($value["city"], $citta)){
					$citta[] = $value["city"]; 
			}
		}
	}
}
 
foreach ($citta as $result) {
  $value = $result;
  $label = $result;
  $items[] = $value.'|'.$label;
}
$items = implode("\n", $items);
 
// Now we need to return the value to the field
return $items;
//</code>

Thank you in advance
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!