• 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.

Update_col with SQL query

Status
Not open for further replies.

jo-ka

Member
Hello.
I have a list with club player records, and I need to set if their renewall for the current season is OK. This is like a status field, on/off, 0/1, enabled/disabled, whatever.

The question is that I need to do this based on the season, this is, I have another list where I have the seasons records and if it's the current season.

So I've set a databasejoin field from the players list to seasons list, where I can filter the current season with a pre-filter and get the id. If I do this mannually it works OK.

Now, what i need is to have a button plugin, update_col, so that the user do'nt have to edit the record to set the season mannually. But I can't figure out if it's possible to have an sql query on the update_col value field, as we have for example in pre-filters, like:

Field Value
{fab_players___season_raw} IN select fab_seasons.id from fab_seasons where fab_seasons.status = current

Is it possible to do this?

Thanks in advance.
 
You wouldn't be able to do it with update_col. The value can be eval'ed, so you can put PHP in there that returns a value, but you don't have access to the row data (placeholders), and all selected rows get the same value.

You'd need to use the PHP plugin, and read the row data yourself.

Not entirely trivial.

-- hugh
 
You wouldn't be able to do it with update_col. The value can be eval'ed, so you can put PHP in there that returns a value, but you don't have access to the row data (placeholders), and all selected rows get the same value.

You'd need to use the PHP plugin, and read the row data yourself.

Not entirely trivial.

-- hugh

Ok, understood. Do you have any example I can follow?
 
So, thanks for the link:

Here's my code:

$db =& JFactory::getDBO();
$ids = JRequest::getVar('ids', array());

foreach ($ids AS $id)
{
$row = $model->getRow($id);
$element = $row->fab_juizes___utilizador;
$element_raw = $row->fab_juizes___utilizador_raw;

$update = "UPDATE fab_juizes SET fab_juizes.epoca = (SELECT fab_epocas.id FROM fab_epocas WHERE fab_epocas.estado = '0' ) WHERE fab_juizes.id=" . (int)$id;

$db->setQuery($update);
$db->query();
}
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top