|
|||||
|
Perl scripts use the DBI interface to access MySQL databases. This interface provides a simple way to add SQL searches to your scripts. To include the DBI in your script, add the DBI module to your script: use DBI; Establish a database connection with a DBI-> connect statement in the following format: $dbh = DBI->connect("DBI:mysql:database-name:hostname",'username','password',{'RaiseError' => 1}); Once connected, you can use the $dbh connection to perform queries with a statement handle: $sth = $dbh->prepare("select
* from mytable"); To view the results of a query, a number of methods are available for the statement handle. The number of returned results is available using: $sth->{'NUMROWS'}; An array of column values is available using: @data = $sth->fetchrow; Together you can iterate through your results: while ($i < $sth->{'NUMROWS'})
{ For more detailed information about MySQL, visit the MySQL web site.
Note: MMA technical support staff cannot provide troubleshooting of problems with third-party CGI scripts including but not limited to: Perl scripts, C/C++ binaries, PHP or web/database integration unless these services are specifically contracted. For these services, please see our Quote Request Form. |
|||||
|
||||||
Copyright
© 1995-2000
Motivational Marketing Associates, LLC
All Rights Reserved.