Gossamer Forum
Quote Reply
MySQL Query??
HI there Wink

I would like to know how I should go do work to convert this:

Code:
my $sql = "SELECT sqrt($dist) AS distance,
Airport_LAT AS latitude,
Airport_LNG AS longitude,
ID AS record_id, Title AS name,
address AS address,
city AS city,
state AS state,
zip AS zip
FROM dz_Links
WHERE $dist < $rad ** 2
ORDER BY $dist
LIMIT 0, $maxSearchRes";

to something like this:

Code:

my $result = $table->select({Airport_LAT},{$dist => $rad ** 2} );

I have read through the documentation that came with the installation, but I am still clueless. If someone could explain it step by step I would really appreciate it Smile

Thank you....


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] MySQL Query?? In reply to
For some more complex queries, its sometimes just easier to use:

Code:
my $sth = $DB->table('Links')->do_query(qq|my $sql = "SELECT sqrt($dist) AS distance,
Airport_LAT AS latitude,
Airport_LNG AS longitude,
ID AS record_id, Title AS name,
address AS address,
city AS city,
state AS state,
zip AS zip
FROM dz_Links
WHERE $dist < $rad ** 2
ORDER BY $dist
LIMIT 0, $maxSearchRes";|) || die $GT::SQL::error;

Hope that helps =)

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] MySQL Query?? In reply to
Thanks Andy. It seems to work.

Is there another way to output "die GT::SQL::error;"? This statement causes problems.
Internal server Errors.... I know there is something wrong with the sql I used (wrong column perhaps), but I don't know how to get the result of the error....

Thanks..[/code]

Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] MySQL Query?? In reply to
Hi,

Cool.

Regarding the 500 IS error, I like to use

Code:
use CGI::Carp qw(fatalsToBrowser);

..then, if an error comes up - the error is outputted to your screen, instead of causing a fatal :)

You can also do something like this:

Code:
my $sth = $DB->table('vvvv')->do_query( query here ) || &error($GT::SQL::error);

sub error {
my $error = $_[0];
print $IN->header;
print Links::SiteHTML::display('error',{ error => $error });
exit;
}

Not tested, but something like that should work :) I've also done it before where it actually emails the admin, with the error code (instead of showing it to the user, which means nothing to them LOL)

Hope that helps.

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] MySQL Query?? In reply to
Thanks Andy, Now I can actually see what is upsetting the server Smile


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] MySQL Query?? In reply to
No problem - its amazing how far a little bit of debugging output can speed up the developing of a plugin/script Smile

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!