I had an issue with a MySQL query containing a sub-query recently where it worked fine when done as a SELECT
query, but gave an error when switching it to a DELETE
query. The error given was something like ‘You can’t specify target table “items” for update in FROM clause’. The sub-query was referencing the same table as the main query, which apparently can’t be done directly in MySQL because the table will be modified during deletion. But there is a sort of a hack I found in this StackOverflow answer, among others, to force it to create a temp table and allow it to work.
solution posts
Firefox: Weird rendering with high contrast mode
I figured out why Firefox 91+ seemed to break some CSS rendering for me (as I blogged about a few weeks back): high contrast mode. I’ve used the accessibility setting “Increase Contrast” on Mac OS for some time to make it easier to see some interface elements. Apparently, via Firefox 91 release notes, “Firefox now automatically enables High Contrast Mode when ‘Increase Contrast’ is checked on MacOS”.
Continue reading post "Firefox: Weird rendering with high contrast mode"Javascript: Submit form with overridden submit method
I come across the situation occasionally where I am trying to submit a form programmatically with javascript, but it happens to contain a field with an id
or name
attribute of submit
.
Automatically reconnect PDO when connection times out
In PHP scripts that run queries to a MySQL database over a long period of time, the connection may time out and give a “MySQL server has gone away” error.
Continue reading post "Automatically reconnect PDO when connection times out"Symfony router: check for match on different host
I found myself wanting to check if a given URL path exists on another host of a multi-host Symfony application from within a controller action. The router service, which is the instance of Symfony’s routing component used to route requests to actions, has a match()
method, but it only accepts the path part of the URL. It also has a matchRequest()
method, but that seems to ignore the HTTP_HOST
and SERVER_NAME
of the passed Request
object.