RikiTikiWiki Progress

Going so well… Thanks to the help and encouragement of Ralf from Neuss, Germany.

Check out this frickin’ awesome nested SQL query that took most of yesterday to flesh out:

strOldWikiWord := Utf8Encode(‘[[' + Trim(OldName) + ']]’);
strNewWikiWord := Utf8Encode(‘[[' + Trim(NewName) + ']]’);

// Create wild card SQL selection using old Wiki Word
strSelectContentSQL := ‘SELECT Content, wiki_id FROM WikiPages WHERE Content LIKE “%’ + strOldWikiWord + ‘%”;’;

// Select
StmtUpdate := DB.Prepare(UpdateContentSQL);
try
Stmt := DB.Prepare(strSelectContentSQL);
try
while Stmt.Step = SQLITE_ROW do
begin
// Retrieve Content
strOldContent := Stmt.Column_Text(0);
// Search and Replace content
strNewContent := AnsiReplaceStr(strOldContent,
strOldWikiWord, strNewWikiWord);
// Update record
StmtUpdate.Bind_Str(1, Utf8Encode(strNewContent));
StmtUpdate.Bind_Int(2, Stmt.Column_Int(1));
StmtUpdate.Step;
StmtUpdate.Reset;
//if Terminated then Exit; // Terminated undeclared
end;
finally
Stmt.Free;
end;
finally
StmtUpdate.Free;
end;

 

Simple, elegant, powerful. FUCK YEAH!

New screen shot:

RikiTikiWiki screen shot

Comments are closed.