1. NOTICE: If you are using Fabrik and update to Joomla 3.10, you will need to update to Fabrik 3.10. And, if you are using Fabrik, do not upgrade to Joomla 4, we do not have a supported version ready for release. More information on a release date coming soon. Also, please note that Fabrik 3.10 will not install on any Joomla sites less than 3.8.
    Dismiss Notice

Element to query

Discussion in 'Community' started by enrb, Nov 17, 2021.

  1. enrb

    enrb Member

    Level: Community
    Good morning,

    I have a form with databasejoin and cascadingdropdown fields where users can choose different options.

    Can I create an item that gives me the value of a query based on the choices made when filling out the form?
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
  3. enrb

    enrb Member

    Level: Community
    I tried to make my query, but it doesn't return any results, also how do I insert into the query the elements to be considered for the final result of the query?

    The query I made is this (following the instructions of the calc element)

    Code (Text):
    $db = FabrikWorker::getDbo();
    $query = $db->getQuery(true);

    $query->clear()
      ->select('mytable.code')
      ->from($db->quoteName('mytable'))
      ->innerjoin($db->quoteName('mytable002') . ' ON ' . $db->quoteName('mytable.id') . ' = ' . $db->quoteName('mytable002.code2'))
      ->where(array(
        $db->quoteName('mytable.id') . ' = ' . $db->quote('{mytable002.code2}')
      ));

    $db->setQuery($query);
    $count = $db->loadResult();
    return $count;
     
  4. troester

    troester Well-Known Member Staff Member

    Level: Community

Share This Page