MySQL Tips & Tricks

Tuesday, June 10, 2008

Perl DBI MySQL read a Record

A secret of programming is to have your own personal library of "primitives" I have them for Perl,PHP & ColdFusion MySQL routines. eg for connecting to MySQL, Inserting/Deleting/selecting records, dumping records into hashes or arrays. The following is a simple Perl DBI MySQL function.

sub fn_read_record_db()
{
$brochure_id=shift;
$sql=qq|select txtdevname from ytbl_development where id='$brochure_id'|;
$sel = $dbh->prepare($sql);
$sel->execute;
if ($hash_ref=$sel->fetchrow_hashref())
{
return $hash_ref->{'txtdevname'};
}
return 'Not Found';
}


Click here Free PHP/MySQL/cPanel Webhosting No ads no catches, I didn't believe it either!

Labels: , ,

0 Comments:

Post a Comment



<< Home