Hi there - probably hi Andy, Robert and Vishal,
I am working with the optimization of queries and wonder if there is an effect if I use
my $brand_id = shift;
my $query = qq|SELECT
Contact_Email
FROM glinks_Links
WHERE
BrandID = ? LIMIT 0,1|;
my $sth = $DB->table('Links')->prepare ($query) || undef;
$sth->execute ($brand_id);
return $sth->fetchrow_hashref;
}over
my $brand_id = shift;
my $query = qq|SELECT
Contact_Email
FROM glinks_Links
WHERE
BrandID = ? LIMIT 0,1|;
return $DB->table('Links')->do_query($query) || undef;
}
While the second is shorter as far as I know it is better and probably faster with mySQL to use placeholders. I yet not figurered out if LinksSQL does call mySQL with placeholders or if both of the above lead to the same request and placeholder micht be more secure.
Thanks for your input
n||i||k||o
I am working with the optimization of queries and wonder if there is an effect if I use
Code:
sub { my $brand_id = shift;
my $query = qq|SELECT
Contact_Email
FROM glinks_Links
WHERE
BrandID = ? LIMIT 0,1|;
my $sth = $DB->table('Links')->prepare ($query) || undef;
$sth->execute ($brand_id);
return $sth->fetchrow_hashref;
}
Code:
sub { my $brand_id = shift;
my $query = qq|SELECT
Contact_Email
FROM glinks_Links
WHERE
BrandID = ? LIMIT 0,1|;
return $DB->table('Links')->do_query($query) || undef;
}
While the second is shorter as far as I know it is better and probably faster with mySQL to use placeholders. I yet not figurered out if LinksSQL does call mySQL with placeholders or if both of the above lead to the same request and placeholder micht be more secure.
Thanks for your input
n||i||k||o