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

Excel MD5 Hash Function

Go to the VB editor (Alt-F11), right-click on your workbook in theproject window, and click…

PowerShell: Move Virtual Machine Storage Using VMM

# moveVmStorageUsingVmm.ps1 # Version 0.01 $vmNames=@( 'TESTVM0001', 'TESTVM0002', 'TESTVM0003' ) $storageLocations=@( 'C:\ClusterStorage\BLOB001', 'C:\ClusterStorage\BLOB002', 'C:\ClusterStorage\BLOB003' )…

Update Host Files on Multiple Servers

$arecord='intranet' $domain='contoso.com' $serverIp='555.555.555.555' $groupTag='# Accounting Servers' $serversToEdit='Accounting1','Accounting2','Watermelon' $commentOut=$false function updateHostFiles{ param( $appLocalIp, $orgName, $domain, $searchString,…