Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DBI & CGI

Posted on 2000-02-26
3
Medium Priority
?
194 Views
Last Modified: 2013-12-25
where can I learn more about CGI.pl and DBI.pl (I think this is what they are called).
0
Comment
Question by:evildogeye
3 Comments
 
LVL 3

Expert Comment

by:monas
ID: 2561524
perldoc CGI

and

perldoc DBI

are command you want to issue...
0
 
LVL 10

Accepted Solution

by:
makerp earned 200 total points
ID: 2562376
if your running activeperl on win32 both modules are well docuemented in the help which youll find on start\activestate. i dont think that dbi comes with activestate but when you install it providing you use ppm the help files will be added.

as far as books go perl in a nutshell provides a chapter on both modules that contain some good examples and complete listings\descriptions on all functions belonging to these modules. perl in a nutshell is only about £14 so its well worth it.

dbi is really easy to use. all you have to do is get the dbi module and then get a dbd module for the database you want to use. dbi provides the interface and framework for vendor specific dbd drivers. the dbd actaully implements the methods which talk to the db.  

dbd modules can be obtained for most dbs from either cpan or activestate\packages\zips. for access use the odbc dbd module, this will work for sql server aswell.

use DBI;
#open the database
$db_handle->connect(dbi:<DBD DRIVER>:<DSN>,'username','password');
#prepare statment
$st_handle = $db_handle->prepare("Some sql ");
#execute it
$st_handle->execute();
#loop through displaying results
while($data = $st_handle->fetchrow_hashref())
{
   print("result : ".$data->{"the_field_name"});
}

see its easy !!. in the connect bit <DSN> is a dsn you have set up for you database, or the address of a db server such as oracle followed by the database name. and <DBD DRIVER> is the name of the dbd driver you want to use. note theres not a use DBD at the top.

some cgi pm

use CGI;
#create a cgi object
$query = new CGI;
#test if there any input parameters
if($query->param())
{
#get on
   $my_value_from_a_form = $query->param('form_value_name');
#print a header out
   print $query->header()
   print loads of html either using lots of print sttments or cgi functions

}                  
                 -
0
 
LVL 1

Expert Comment

by:stephenblade
ID: 2594585
Or actually you can read a step by step tutorial on the subject at:

http://perl.about.com/compute/perl/library/weekly/aa120699a.htm

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question