Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Monks who also work in PHP, help me upgrade my SQL code?

by Cody Fendant (Pilgrim)
on Feb 28, 2013 at 00:18 UTC ( #1020978=perlquestion: print w/ replies, xml ) Need Help??
Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question:

This is probably pretty primitive for Perl programming, but I code my SQL like this:

$sth = $db_handle->prepare("select foo from bar where id = ?") or die( $db_handle->errstr ); $id = 17; ## or whatever $sth->execute( $id ) or die ( $sth->errstr() ); $baz = $sth->fetchrow_hashref();

I'm working more and more in PHP in a current job and I see nothing like that in the code I'm working with, no binding, just raw SQL commands constructed by variable/string concatenation and fed direct to mysql_query().

What's the professional way to do this in PHP?

Comment on Monks who also work in PHP, help me upgrade my SQL code?
Download Code
Re: Monks who also work in PHP, help me upgrade my SQL code?
by Gangabass (Priest) on Feb 28, 2013 at 04:18 UTC
Re: Monks who also work in PHP, help me upgrade my SQL code? (bobby-tables)
by Anonymous Monk on Feb 28, 2013 at 05:11 UTC
Re: Monks who also work in PHP, help me upgrade my SQL code?
by tobyink (Abbot) on Feb 28, 2013 at 07:56 UTC

    PDO.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1020978]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-12-26 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls