Help Required regarding Database Operations

Help Required regarding Database Operations

am 29.12.2005 07:26:59 von bhavin_s18

I am a novice user to PERL. Plz help me regarding
following information
Suppose there is a MySQL DB say X, with Server Y, User
XY, Password XYZ and Table ABC.
How do i get fieldsNAmes of a Table in a Array?
Also for PHP as we have phpinfo() function, what is a
similar function in PERL?

Regards
Bhavin

New Document

Send instant messages to your online friends http://in.messenger.yahoo.com

Re: Help Required regarding Database Operations

am 29.12.2005 14:51:46 von gonzales

On Thu, 29 Dec 2005, Bhavin Shah wrote:

> I am a novice user to PERL. Plz help me regarding
> following information
> Suppose there is a MySQL DB say X, with Server Y, User
> XY, Password XYZ and Table ABC.

> How do i get fieldsNAmes of a Table in a Array?
This is not consistent with your example above!

> Also for PHP as we have phpinfo() function, what is a
> similar function in PERL?
This is a PERL/DBI group, NOT PHP. PLZ find a PHP group to help with PHP
questions.

>
> Regards
> Bhavin
>
> New Document
>
> Send instant messages to your online friends http://in.messenger.yahoo.com
>

--
Louis Gonzales
louis.gonzales@linuxlouis.net
http://www.linuxlouis.net

Re: Help Required regarding Database Operations

am 29.12.2005 18:34:29 von Tim.Bunce

On Thu, Dec 29, 2005 at 06:26:59AM +0000, Bhavin Shah wrote:
> I am a novice user to PERL. Plz help me regarding
> following information
> Suppose there is a MySQL DB say X, with Server Y, User
> XY, Password XYZ and Table ABC.
> How do i get fieldsNAmes of a Table in a Array?

Something like

use DBI;
$dbh = DBI->connect("dbi:mysql:host=Y;database=X", "XY", "XYZ");

then either use the column_info() method or, if you're going to be
selecting from the table anyway, you could

$sth = $dbh->prepare("select * from Table");
@fieldsNAmes = @{$sth->{NAME}}; # or NAME_lc or NAME_uc

> Also for PHP as we have phpinfo() function, what is a
> similar function in PERL?

Perhaps the Config module has whatever it is you're looking for.

See also http://www.catb.org/~esr/faqs/smart-questions.html

Tim.