Solved Calc error for php query

chrisyork

Member
I have just installed Fabrik 4Z on a fresh Joomla 5 installation (no other components). I'm a bit rusty with Fabrik...

I have tried a calc formula with Axaj triggered by a database join element [called link] on the same form, looking to return a row from another table based on the id being equal to the selected item (raw) on my dropdown. I followed the wiki for common php Joomla 4+ queries, so the code should look vaguely 'familiar'...


// Get a db connection in Joomla 4+ (adapted code).
$db = \Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');

// Create a new query object.
$myQuery = $db->getQuery(true);
$myQuery
->select(array('name','summary','basic', 'intermediate'))
->from('sio_table')
->where('id = ' . $db->quote('{feedback___link_raw}'));

// Assign the query to the db
$db->setQuery($myQuery);

// Load the results as an array of objects.
$rows = $db->loadObjectList();

//output result as an ordered list
$list = array();
foreach ($rows as $row)
{
$list[] = "<li>" . $row->name . " " . $row->summary . "</li>";
}
return "<ol>" . implode($list) . "</ol>";​

It dies quietly, so this is the debug: information -

Debug: Eval exception : existing_items (id 70)::_getV() :
[then obviously the above code, no point repeating it]​
Since joomla/database 2.2.0: The parameter $new is deprecated and will be removed in 4.0, use Joomla\Database\DatabaseDriver::createQuery() instead.​

I don't really get that as I'm not knowingly using $new... so wondered if there is an error in my code or a bug that stops this element working?

Thanks for any help
 
Oh... SELF HELP!

Change

$db->getQuery(true);

to

$db->createQuery(true);

and it works!

I misdirected myself by not seeing that getQuery is the problem of $new in the error...

Could be worth updating this on the Wiki?
 
It's a deprecated message which only will show up (and so may break expected JSON responses) if you have J! system debug enabled.
getQuery() is still working normally in J!5.
But yes, createQuery() will fix this;
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top