• 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 Events onpreload

Maud67

New Member
Hi,

I hope that somebody can advice me on the following:

I have two big tables/lists.

One will be updated every week with data (import) for the next week.
The other one will be updated every weekday with data (import) for the next weekday.

On the second list I have a php events plugin with the following code:

$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);

$myQuery
-> update('jos_1b_import_transporter_daily1 AS t')
-> join('INNER','jos_1b_import_transporter AS a ON t.projekt_namn = a.projekt_namn')
-> set('t.text_1 = a.trailertyp_ba')
-> where('t.lass_nr = a.lass_nr AND t.leverans_datum >= NOW()');

$myDb->setQuery($myQuery);
$myDb->execute();

This I have three times for three columns.

Please note that the "leverans_datum" is a field and no date element.

Without the code the list loads normal.
With the code the list loads slow.

What do I do wrong and how can I improve the loading speed?

Thanks a lot!
 
Do you have indexes for all relevant elements (projekt_namn, lass_nr, leverans_datum)? You must create them directly in your database.

Why do you run the code three times? You can set three columns in one query.
 
Hi Troester,

Thanks for responding.

I just finished checking the indexes and they are ok.

I know that I can put it in one query but I'm not sure how.
I did read it somewhere in a threat where Hugh explained how but I cannot find it.

Can you help me please?

Thanks!
 
Hi Troester,

I was thinking, I guess I can copy add the other two set rows.

I will try that.

Thanks!
 
set (' x1= y1, x2=y2') should do

if it's the same condition

Gesendet von meinem SM-G930F mit Tapatalk
 
You can either do what Troester suggested, or use multiple set() function. I prefer to do the latter, as it makes it clearer in the code you are setting multiple fields ...

Code:
$myQuery
->update('jos_1b_import_transporter_daily1 AS t')
->join('INNER','jos_1b_import_transporter AS a ON t.projekt_namn = a.projekt_namn')
->set('t.text_1 = a.trailertyp_ba')
->set('t.foo = a.foo')
->set('t.bar = a.bar')
->where('t.lass_nr = a.lass_nr AND t.leverans_datum >= NOW()');

-- hugh
 
Also, as Troester says, make sure you have indexes on anything you join on, and anything you filter on ... so t.projekt_namn, a.projekt_namn, t.lass_nr, a.lass_nr , t.leverans_datum. If you have filters in Fabrik set up on those elements, you may already have indexes, but definitely check with phpMyAdmin (or whatever), and if necessary add them by hand - standard BTREE indexes are fine.

-- hugh
 
Hi Hugh,

A little late sorry, but I have indexes on every element.
It is working fine now.

Thanks a lot!
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top