#__fields_values table issues

30 views
Skip to first unread message

MonkeyT

unread,
Jul 19, 2022, 4:21:48 PM7/19/22
to Joomla! General Development
I truly hate the #__fields_values table in Joomla4.

It has no primary key, relying on querying against a combination of field_id and item_id.  I understand that.

But if I create a MySQLI query "REPLACE INTO #__fields_values VALUES ( 7, 155, 1111 )" and apply it using $dbo->execute( $query ), it fails with literally no impact at all - no error gets thrown, no exception is created, and no change is made to the table's data. If I copy and paste that very same query into PhpMyAdmin (with the correct table name), it works perfectly, with no issues.

FieldsHelper has no method to add/create records, even though it has the means to retrieve those records.  I can't find a way to successfully instantiate a FieldModel which does seem to have a save function.

To update one value in this three field record, the Joomla source code appears to manually delete that record with one query (whether it actually exists or not), and re-insert it with another query (which is precisely what REPLACE INTO should be doing.)

WTH?

I need to update a user's custom field values using data from a third-party component instead of forcing that user to manually edit their user profile, but trying to update this database table fails in every way possible. Even the PhpMyAdmin interfaces won't edit it because it has no Primary Key.

A three field table should never cause this much frustration.

Does Joomla4 provide some simple update method for this data and just fail to mention it?

MonkeyT

unread,
Jul 19, 2022, 4:29:30 PM7/19/22
to Joomla! General Development
Dammit, I hate when I get fixated on one problem, only overlook a simpler one.  It's not $dbo->execute( $query ), it's $dbo->setQuery( $query ); $dbo->execute();.

Sorry I wasted your time.

Reply all
Reply to author
Forward
0 new messages