?
avatar 810
810
10 Dec 2019

Steps to reproduce the issue

Enable debug.

Login backend.

Expected result

1x the query

Actual result

2x the query

System information (as much as possible)

Nightly build

Additional comments

UPDATE `x3j0d_update_sites`
SET `enabled` = :enabled
WHERE `update_site_id` = :id

UPDATE `x3j0d_update_sites`
SET `enabled` = :enabled
WHERE `update_site_id` = :id
avatar 810 810 - open - 10 Dec 2019
avatar joomla-cms-bot joomla-cms-bot - change - 10 Dec 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 10 Dec 2019
avatar richard67
richard67 - comment - 10 Dec 2019

As you can see the query uses bind variables (the things starting with colon). These may have different values, and for sure they have at least different values for :id, because the statement is used to update status of an update site for a particular if, and so it is not a duplicate query.

avatar richard67
richard67 - comment - 10 Dec 2019

P.S. Please close your issue due to reasons stated in my previous comment. I could close it for you, but I prefer not to use this power.

avatar 810
810 - comment - 10 Dec 2019

when i set it to old id, then i got just 1 query

$db = $this->parent->getDbo();
		$query = $db->getQuery(true)
			->update($db->quoteName('#__update_sites'))
			->set($db->quoteName('enabled') . ' = :enabled')
			->where($db->quoteName('update_site_id') . ' = ' . $update_site_id)
			->bind(':enabled', $enabled, ParameterType::INTEGER);
		$db->setQuery($query);
avatar mbabker
mbabker - comment - 10 Dec 2019

Again, just because the text of the query is the same does not mean it is a duplicated query. Please confirm whether the query is being executed for a single row multiple times or for multiple rows. Without a confirmation that the query is being executed multiple times for one row, this is not an issue report that can be processed in any way other than closing it.

avatar 810 810 - change - 10 Dec 2019
Status New Closed
Closed_Date 0000-00-00 00:00:00 2019-12-10 16:51:41
Closed_By 810
avatar 810 810 - close - 10 Dec 2019
avatar richard67
richard67 - comment - 10 Dec 2019

That's the disadvantage of parametrized queries or prepared statements or however you call it: They are parsed on server side (including bind variable replacement), and so in debug we don't see the final query. Not sure if this can be changed to be parsed on client side. I've once seen such option in an ODBC driver, I think I remember, but I'm not 100% sure.

avatar Quy
Quy - comment - 10 Dec 2019
avatar richard67
richard67 - comment - 10 Dec 2019

@Quy I saw that one. But I'm not sure if there is a solution, except of replacing the bind vars on client side just for debugging, but there would not be a guarantee that we see the same query as the server does. It just needs some mistake when doing thatz replacement, and you see something in the debugger which is not equal to what the db server executes.

avatar mbabker
mbabker - comment - 11 Dec 2019

@richard67 there are already plenty of libraries that have logic for replacing parameters with their parameterized values (the Laravel extension of the PHP Debug Bar used in 4.0 has support for this, and somewhere within the code used by the DoctrineBundle for Symfony is code to show an executable query). So it's really not as brittle as you might think it is.

avatar richard67
richard67 - comment - 11 Dec 2019

@mbabker That‘s good to know. That will save a lot of work. Thanks for the info.

Add a Comment

Login with GitHub to post a comment