[rt-users] perl and mysql

Micah Anderson micah at colltech.com
Wed Aug 8 17:12:57 EDT 2001


This works for me:

$db_handle = DBI->connect
                      ("DBI:mysql:$DATABASE:$location:port_num", 
                        $username, $password, $dbi_options )
                        || die ("Connection error: $DBI::errstr");
			

$result = $db_handle->prepare("SELECT * FROM $TABLE");
$result->execute();
 

while (my ($owner, $address, $nickname, $fullname) = 
        $result->fetchrow_array())

 {

 print "$owner, $address, $nickname, $fullname\n";
 
 }
 
On Mon, 06 Aug 2001, Matthew Frick wrote:

> When using a query like where the query_string is a select that returns multiple
> rows of a column in the database
> 
> $result = $dbh->Query($query_string) or warn "Query had some problem: $Mysql::db_errstr\n";
> 
> 
> 
> eg. I may be getting this to return every name starting with 'M' therefore it
> should return Matt,Mike,Malcom
> 
> but how do I get these values out I have tried a few things and the alot of
> the online stuff I have looked at says that this should work...
> 
> @arr = $result->fetchrow;
> 
> but this only ever returns the first returned result from the query and that
> is it.
> 
> I appologise for this not being a 100% rt problem but I figure there just maybe
> one of you out there that can help me.
> 
> Matthew Frick.
> 
> _______________________________________________
> rt-users mailing list
> rt-users at lists.fsck.com
> http://lists.fsck.com/mailman/listinfo/rt-users

-- 
Micah Anderson
Collective Technologies
www.colltech.com

"To be and not to do is not to be at all"




More information about the rt-users mailing list