SQL problem

Bernard Devlin bdrunrev at gmail.com
Mon May 4 14:24:27 EDT 2009


On a stylistic point I'd like to propose my way of constructing
statements to be executed.

Instead of this:

put "INSERT INTO 'terry_dbname'.'tablename' ('login' , 'ww' ,
'toegang') VALUES ('" & $_GET["login"] & "', '" & $_GET["ww"] & "', '"
& $_GET["toegang"] & "');" into tSQL

I would write this:

put "INSERT INTO 'terry_dbname'.'tablename' ('login' , 'ww' ,
'toegang') VALUES( '[[tLogin]]' , '[[tWW]]' , '[[tToeGang]]' );" into
tTemplateSQL

put $_GET["login"] into tLogin
put $_GET["ww"] into tWW
put $_GET["toegang"] into tToeGang

put merge(tTemplateSQL) into tSQL.

It is more verbose but I find it far less error-prone than other
constructions as my mind gets very confused by a profusion of double
quotes, single quotes, ampersands, etc.

Just my tuppenceworth.

Bernard

On Mon, May 4, 2009 at 4:19 PM, Terry Vogelaar <tvogelaar at de-mare.nl> wrote:
> Hi all,
>
> I am struggling to get a MySQL database filled. The idea is to use a form
> that calls an irev file, that in turn adds to the database.
>
> Here is the script:
> <?rev
> put
> revOpenDatabase("mysql","localhost","terry_dbname","terry_dbuser","password")
> into tConID
>
> # Construct SQL
> put "INSERT INTO 'terry_dbname'.'tablename' ('login' , 'ww' , 'toegang')
> VALUES ('" & $_GET["login"] & "', '" & $_GET["ww"] & "', '" &
> $_GET["toegang"] & "');" into tSQL
>



More information about the use-livecode mailing list