Placeholders don't add speed as far as I'm aware. They just stop someone doing a SQL injection into your query (or breaking the query).
For example, if "Brand" was: 'the "future" starts now', then it would create the query:
Which would obviously break the query. Someone more malicious could use that to hijack your query and do stuff in the DB
If you are happy the query is sanitized, I would just stick with something like:
my $query = qq|SELECT
Contact_Email
FROM glinks_Links
WHERE
BrandID = "$brand_id" LIMIT 1|;
return $DB->table('Links')->do_query($query)->fetchrow || undef;
Unless you are doing some serious amount of queries (hundreds or thousands per page), then I don't think you will find it makes a difference. Obviously make sure you have an index on BrandID as well though!
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!
For example, if "Brand" was: 'the "future" starts now', then it would create the query:
Code:
SELECT * FROM glinks_Links WHERE Brand = "the "future" starts now";Which would obviously break the query. Someone more malicious could use that to hijack your query and do stuff in the DB
If you are happy the query is sanitized, I would just stick with something like:
Code:
my $brand_id = shift; my $query = qq|SELECT
Contact_Email
FROM glinks_Links
WHERE
BrandID = "$brand_id" LIMIT 1|;
return $DB->table('Links')->do_query($query)->fetchrow || undef;
Unless you are doing some serious amount of queries (hundreds or thousands per page), then I don't think you will find it makes a difference. Obviously make sure you have an index on BrandID as well though!
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!