I've been bouncing some ideas around after reading these: Tao::DBI::st, DBIx::bind_param_inline, Method::Signatures, Devel::Declare, DBI recipes#Binding columns and fetching
SELECT $dbh,
":name, :email from ... where DIAPER=?",
'soft and absorbant'
{
print "$name < $email >\n";
}
|
SELECT $dbh,
" :name, :email
from ...
where
DIAPER LIKE ?
",
'soft and absorbant'
{
print "$name < $email >\n";
}
|
SELECT $dbh,
":name, :email from ... where DIAPER=?",
'soft and absorbant' {
print "$name < $email >\n";
}
|
SELECT $dbh,
" :name, :email
from ...
where
DIAPER LIKE ?
",
'soft and absorbant' {
print "$name < $email >\n";
}
|
$dbh->SELECT
":name, :email from ... where DIAPER=?",
'soft and absorbant'
{
print "$name < $email >\n";
}
|
$dbh->SELECT
" :name, :email
from ...
where
DIAPER LIKE ?
",
'soft and absorbant'
{
print "$name < $email >\n";
}
|
$dbh->SELECT(
":name, :email from ... where DIAPER=?",
'soft and absorbant',
sub {
print "$name < $email >\n";
});
|
$dbh->SELECT(
" :name, :email
from ...
where
DIAPER LIKE ?
",
'soft and absorbant',
sub {
print "$name < $email >\n";
} );
|
for my $quality ( 'soft', 'absorbant' ){
SELECT ":rec{name}, :rec{email} from ... where DIAPER=?", $quality
+ {
print "$rec{name} < $rec{email} >\n";
}
}
|
Say these are lines 2 3 4 5 6 in file foo.pl for my $quality ( 'soft', 'absorbant' ){
SELECT ":{name}, :{email} from ... where DIAPER=?", $quality {
print "$rec{name} < $rec{email} >\n";
}
}
So through some Devel::Declare type magic that becomes
{
my %rec = (
name => undef,
email => undef,
);
# line 3 foo.pl
my $sth = $dbh->prepare( "SELECT name, email from ... where DIAPER
+=?" );
# line 3 foo.pl
$sth->execute( $quality );
$sth->bind_col(1, \$rec{name});
$sth->bind_col(2, \$rec{email});
while( $sth->fetchrow_arrayref ){
# line 4 foo.pl
print "$rec{name} < $rec{email} >\n";
}
}
# line 7 foo.pl
|
But my thinking isn't clear, any ideas?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|