(RADIATOR) Database access from hook files

Martin Edge martinedge at kbs.net.au
Tue Jul 20 02:01:19 CDT 2004


Yep, code snippet is below:


# Find the object which connects to the db we want, look using Identifier
specified
my $auth_object = Radius::AuthGeneric::find("IdentifierUsedInConnection");

# Could we find the object?
if (!$auth_object) {
	&main::log($main::LOG_DEBUG, "My Log Message to suggest badness");
	
 	...
} else {
	
	# The query I want to execute
	my $query  = "select stuff from foo where bar = 2";

	# Prepare and Execute
	my $sth = $auth_object->prepareAndExecute($query);

	# Was there a statement handle created?
	if ($sth) {
		# Use appropriate functions from within the DBI::?? Module
you are using to access data
		my $bit_of_data = ($sth->fetchrow())[0];

		$sth->finish();

		...
      } else {
		&main::log($main::LOG_DEBUG, "My Log Message to suggest more
badness");
	}
}



> -----Original Message-----
> From: owner-radiator at open.com.au 
> [mailto:owner-radiator at open.com.au] On Behalf Of Denis Dowling
> Sent: Tuesday, 20 July 2004 3:49 PM
> To: radiator
> Subject: (RADIATOR) Database access from hook files
> 
> Just wondering if anyone has an example of how to get the 
> database handle in a hook file. I am currently just creating 
> a new database connection with:
> 
> my $dbh = DBI->connect( 'dbi:Oracle:xxx', 'xxx', 'xx' ) || 
> die "Could not connect to the database: DBI:errstr";
> 
> There is a lot of code in SqlDb.pm that handles database 
> failover and timeout that would be nice to use as Radiator in 
> this instance is configured to fall back to a backup database 
> if the primary is offline. I also want to ensure that the 
> hook file uses the same database as the Auth realm is using.
> 
> Regards,
> Denis
> 
> 
> 
> --
> Archive at http://www.open.com.au/archives/radiator/
> Announcements on radiator-announce at open.com.au To 
> unsubscribe, email 'majordomo at open.com.au' with 'unsubscribe 
> radiator' in the body of the message.
> 

--
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.


More information about the radiator mailing list