• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

PHP onlist load concat

jh

Member
Hi

I have been testing a search/filter field which is created by concat, using the php plugin onload. The fields are a regular text field ('factory_name') and a database join field ('country_retest'). The following code is sort of working:

$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->update('factory_table')->set('php_testing = concat(factory_name, \' \',country_retest)') ;
$myDb->setQuery($myQuery);
$myDb->execute();

However it shows the ID of the database join element, not the label/value. I think I need to access the value of the field and have tried to do so by following the wiki, but I seem to keep running into error messages.

If someone could kindly show me how to access the value correctly (not the ID) I would be very greatful.

Kind Regards
 
You'll have to left join the countries table and get the 'country_name' (or whatever the field name is) from that ...

Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->update("factory_table")
   ->leftJoin("countries on countries.id = factory_table.country_retest")
   ->set("php_testing = concat(factory_name, ' ',countries.country_name)") ;
$myDb->setQuery($myQuery);
$myDb->execute();

Replace table and field names as required.

-- hugh
 
  • Like
Reactions: jh
Hi

Sorry to bother you again but I wanted to do a similar PHP but with the IDs coming from a repeat group. I have got the IDs using the following (so eg 2,5,11) is returned, working correctly:

$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->update('pattern_table as d')
->set('d.php_col = (SELECT GROUP_CONCAT(themes_retest) FROM pattern_table_repeat_themes_retest as p WHERE p.parent_id = d.id)');
$myDb->setQuery($myQuery);
$myDb->execute();


So I guess I needed to join pattern_table_repeat_themes_retest to themes (the table holding the data) to get the labels/values. But even after many attempts of trying to use ->leftJoin to join to the repeat group all I get is error messages.

If you could kindly help I would be extremely greatful.

Kind Regards
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top