I had a problem need to optimize following 3 query in one. can I create a function?
$query = "UPDATE #__sbc SET payment_reference ='".$payref."', payment_status = '".$state."' WHERE reference ='".$ref."'";
$db->setQuery($query);
$db->query();
//update allforms table
$query = "UPDATE #__allforms SET payment_reference ='".$payref."', payment_status = '".$state."' WHERE reference ='".$ref."'";
$db->setQuery($query);
$db->query();
$query = "UPDATE #__printxml SET payment_reference ='".$payref."', payment_status = '".$state."' WHERE reference ='".$ref."'";
$db->setQuery($query);
$db->query();
You can combine queries by adding semi column (;) to the end of the query. For example:
UPDATE TABLE1 SET `field1`=2 WHERE `id`=5;UPDATE TABLE1 SET `field1`=3 WHERE `id`=6;
The thing is, combining queries is unlikely to provide any (even slightly) noticeable performance boost.