Binding Columns : DBI « Database « Perl

Home
Perl
1.Array
2.CGI
3.Class
4.Data Type
5.Database
6.File
7.GUI
8.Hash
9.Language Basics
10.Network
11.Regular Expression
12.Report
13.Statement
14.String
15.Subroutine
16.System Functions
17.Win32
18.XML
Perl » Database » DBI 




Binding Columns
   

use DBI;
my $driver="DBI:mysql";
my $database="sample_db";
my $user="root";
my $host="localhost";

my $dbh = DBI->connect("$driver:database=$database;host=$host;user=$user")or die "Can't connect: " . DBI->errstr;
my $sth=$dbh->prepare("SELECT name FROM Employee"or die "Can't prepare sql statement" . DBI->errstr;

$sth->execute() or die "Can't prepare sql statement". $sth->errstr;
my($name);
$sth->bind_columns(\$name);
printf"\t%-20s%\n","Name"
while$sth->fetch()){
     printf "   %-25s\n",$name;
}

$sth->finish();
$dbh->disconnect();

   
    
    
  














Related examples in the same category
1.Listing Currently Installed Drivers
2.Listing Valid DSNs
3.Talking with the Database
4.The connect() Method
5.Use DBI to connect to a database
6.Connect to Oracle
7.Connect to mysql
8.Available DBI Drivers and Data Sources
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.