?
Solved

DBI & CGI

Posted on 2000-02-26
3
Medium Priority
?
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

719 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