it fixes the issue I have this bit of code which finds the ID of the logged in user, finds all of the customers that are related to that user and stores the 'custref'(id) into an array: , Here is the shortest way.
hop of those help? It does not matter if you clone query or not. sum() performs actual SQL query - if you call it three times, you will get three queries. From microptimization perspective clone should be faster than creating the same query object three times. But you will not see much difference - performing real SQL query will be main bottleneck here, PHP overhead will be negligible.
Yii2 query mysql, Adding A Column that doesn't exist in a query