There are multiple places in the code base where the database object is not cached as a variable for re-use. As a result, the code is not DRY and developers may be initially confused by inconsistency when they expect to see $db->quoteName() but $query->quoteName() is written. There are some occurrences where $this->getDbo() is called multiple times within the same method which is not ideal / best practice (I found one occurrence within a loop).
The advised fix does not need to change any behavior and as far as I can tell there is no bug in the current implementation.
To find the occurrences just search on "$this->getDbo()" in your IDE and observe the number of times the getDbo() method is called. If more than one, then declare a variable on the first call and re-use the variable on all subsequent occurrences. If the getDbo() method is called over and over within a loop, declare $db prior to entering the loop and only use $db within the loop.
Labels |
Added:
?
|
Yes, this is a good codestyle, however as @brianteeman stated, pull requests would be welcome. Otherwise I would vote to close this issue for now.
@mickmackusa sir, I have found multiple occurrences of "$this->getDbo()", so, sir can you please upload an screenshot to approach this, so that I will accordingly, and will change in the best manner, thanks in advance :)
Labels |
Added:
?
No Code Attached Yet
Removed: ? |
Pull requests are welcome