>Extracted from the perl cookbook
>
>use DBI;
>
>$dbh = DBI->connect('DBI:driver:database', 'username', 'auth',
>            { RaiseError => 1, AutoCommit => 1});
>$dbh->do($SQL);
>$sth = $dbh->prepare($SQL);
>$sth->execute();
>while (@row = $sth->fetchrow_array) {
>    # ...
>}
>$sth->finish();
>$dbh->disconnect();
>
>Concerning this code i have some questions ( i thinks it is very
badly
>documented in the man pages)
>
>-what does '->' stand for ?
>- what does prepare do ?
>- is there a _GOOD_ documentation about this ? I just want some
sample code
>how to make some selects that return multiple data, and than see how
the
>multiple rows are handled with ...
>

good info on using the DBI module (should take you right to prepare):
http://theoryx5.uwinnipeg.ca/CPAN/data/DBI/DBI.html#prepare

There is also a good O'Reilly book titled "Using the Perl DBI" (or
something like that) by Alligator Descartes

-> is the dereference operator--the cookbook won't teach you much
about it

In your case, the $dbh = DBI... returns a database handle(=a
reference to a database object in OO speak).
Then the >$dbh->do($SQL);   runs the do method of the $dbh object

The code you've copied from the cookbook is a bit of nonsense meant
as an example. To make it work you have to fill in the driver, the
database name etc. in the DBI->connect call and you have to put a
legal SQL statement in the $SQL variable.  This is covered in the
above DBI documentation.  In my copy of the cookbook, example 14-7 is
a more nearly working example, but you would still have to point it
to your database.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to