Posted On March 31, 2019

Gallery2 Random Highlight Mod

kimconnect 0 comments
blog.KimConnect.com >> Codes , Database >> Gallery2 Random Highlight Mod
There's a SQL technical limitation where one may not update a table based on its nested View. Thus, the work around for that would be creating an alias table with the returns of a Select statement. Then, it would be possible to run an update on the original table based on the new alias. A demonstration is as follows:
CREATE TABLE a_random
SELECT g2_Entity.g_id, g2_Entity.g_onLoadHandlers
FROM g2_Derivative
INNER JOIN g2_ChildEntity ON g2_Derivative.g_id = g2_ChildEntity.g_id
INNER JOIN g2_Entity ON g2_Derivative.g_id = g2_Entity.g_id
WHERE
g2_ChildEntity.g_parentId IN
(SELECT g_id FROM g2_Entity WHERE g_entityType = 'GalleryAlbumItem')
AND g2_Derivative.g_derivativeType = 1;
---------------------------------------------------------------------------------------------------------------
UPDATE g2_Entity a, a_random c
SET a.g_onLoadHandlers='|RandomHighlight|'
WHERE a.g_id = c.g_id
The example above is an actual SQL statement ran against a mySQL database. The exact application is Gallery2 RandomHighlight module's recursive update on nested folders.

================================================================================================

How to do a Search and Replace in mySQL:
update `_vldmembers` set username = replace(username, '%', '_')

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Disable Virtual Machine Queuing on Hyper-V Hosts

What is VMQ? Virtual Machine Queuing is a shortcut to deliver packet data from the…

SQL AlwayOn High Availability Default Port

Internal SQL DEV & QA environments may have SQL listening to the default port of…

How to Install Secured Shell SSH on Windows

# Windows 10 & Server 2019 # Install the OpenSSH Server Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0…