in reply to easier to get data from a database
I'm not sure exactly though.. it doesn't appear to me that your code works if trying to select out all the rows.. But be sure to read through the DBI docs (perldoc DBI) and look at all the select* methods available.use DBI; my ($db_name,$host_name,$port,$db_user,$db_pass,) = @_; my $database = "DBI:mysql:$db_name:$host_name:$port"; my $dbh = DBI->connect($database,$db_user,$db_pass); my ($table, $col, $value) = ('clients', 'client_id', $client_id); my $sql = "select * from $table"; if( $value ){ $sql .= " where $col = ?"; push @bind, $value; } my $href = $dbh->selectall_hashref($sql, $col, {}, @bind);
|
|---|