Help for this page

Select Code to Download


  1. or download this
    # $dbh contains your database handle
    my $sth = $dbh->prepare( "SELECT * FROM foo WHERE id = ? AND bar = ?" 
    +) or die( "Could not prepare statement: ".$dbh->errstr() ); #of cours
    +e you will have a more elegant error handling method than just die
    $sth->execute( $value_for_id, $value_for_bar );
    #and then just fetch the data like you would normally.
    
  2. or download this
    #Take the same $sth from the previous example
    my @data_to_query = ( #You would probably get this from somewhere else
    ...
        $sth->execute( $_->{id}, $_->{bar} );
        #do something with that dataset
    }