English English Spanish EspañolKorea한국어
Straker»Company»Blog»2005» Rename site code snippet from Alex

Rename site code snippet from Alex

Glenn, Thanks for the help with this, the script in this case didntwork for me as i think the regex wasnt matching unquoted values, asthe old editor didnt always put in " or '. I changed the script tocut out the regex and replace it with a pure string replace, and inmy mind thats fine because if im searching for /demo_01/ and wantto replace with /aimhigher/ then it should never occur outside ofthat. And in fact global replace should maybe do just that replace

X with Y and then it does what it says on this tin in terms ofglobal replace. Ripped my hair out for a while when it kept sayingdone and not finding any containers but then remembered theapp_containers folder needed clearing. fun fun :-) Alex. ps modded

code below in case its useful maybe straker blog ?

<cfscript>
dataSource = "aimhigher";
stArgs = structNew();
stArgs.content = "";
stArgs.oldValue = "demo_01";
stArgs.NewValue = "aimhigher";
</cfscript>
<h1>Getting Containers</h1>
<cfflush>
<!--- Get Container versions--->
<cfquery name="qCcontainerVersions" datasource="#dataSource#">
select *
from container_versions
where content like <cfqueryparam value="%#sArgs.oldValue#%"
cfsqltype="CF_SQL_VARCHAR">
</cfquery>
<cfflush interval="100">
<cfloop query="qCcontainerVersions">
<!---
<cfset stArgs.content = content>
<cfset stResult =
replaceInValuePair(argumentCollection=stArgs)>
--->
<cfif content contains
stArgs.oldValue>
<cfset
stResult.contentAfter=replace(content,stargs.oldvalue,stargs.newvalue,"all")>
<cfset stResult.contentChanged="true">
</cfif>
<cfif
stResult.contentChanged>
<cfquery name="qUpdate" datasource="#dataSource#">
update container_versions
set content = <cfqueryparam value="#stResult.contentAfter#""CF_SQL_LONGVARCHAR"> cfsqltype=
where version_uuid = <cfqueryparam
value="#version_uuid#" cfsqltype="CF_SQL_VARCHAR">
</cfquery>
</cfif>
Updated: <cfoutput>#version_uuid#</cfoutput><br>
</cfloop>
<h1>Done!</h1>


Comments

There are no comments for this page as yet.

Add a comment