Gossamer Forum
Home : Products : Gossamer Links : Discussions :

SQL command in nph-build.cgi

Quote Reply
SQL command in nph-build.cgi
Hi-

I need to place an SQL command in nph-build.cgi. If I were placing it in the SQL Monitor the command that works is:

UPDATE lsql_Links

SET Level_Sort = '1'
WHERE Level = 'Featured'

To place it in nph-build.cgi I think it would go something like:

$DB->table('Links')->update ( { Level_Sort => \'1' WHERE Level = 'Featured'});

But this doesn't seem to be doing the trick. I think it's probably something off with the text in red. Does anyone know the proper syntax to get this to work?

--Frank
Quote Reply
Re: [FrankM] SQL command in nph-build.cgi In reply to
Hello,

Could you try this:

$DB->table('Links')->update ( { Level_Sort => \"Level_Sort + 1" },
{ Level => 'Featured' } );


and see if it works?
Quote Reply
Re: [ridesworld] SQL command in nph-build.cgi In reply to
Don't you mean;

$DB->table('Links')->update ( { Level_Sort => 1 },
{ Level => 'Featured' } );

Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] SQL command in nph-build.cgi In reply to
Hello

If Level_Sort should be 1 and not a count, yes you've right!
Quote Reply
Re: [ridesworld] SQL command in nph-build.cgi In reply to
Hi-

Thanks very much for your help. For the record, I needed the integer value of 1 placed in the Level_Sort field which is an INT field, and found that the following code worked in nph-build.cgi:

$DB->table('Links')->update ( { Level_Sort => \'1' }, { Level => 'Featured' } );

Thanks again.

--Frank
Quote Reply
Re: [FrankM] SQL command in nph-build.cgi In reply to
You shouldn't need the \'' bit, as GT::SQL automatically quotes numbers... so you could just use;

$DB->table('Links')->update ( { Level_Sort => 1 }, { Level => 'Featured' } );

I'd imagine it just speeds things up a little bit, as its less for GT::SQL to do.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] SQL command in nph-build.cgi In reply to
Thanks Andy. I just tested that and it worked fine.

--Frank