CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Assigning an object to a variable of instance of a class

 



gorums
New User

Mar 11, 2010, 11:26 AM

Post #1 of 1 (1503 views)
Assigning an object to a variable of instance of a class Can't Post

Hola, people I have a great problem, since I do not speak Englishman am going to be concise.

I have a class


Code
 

package WacidCon;

sub new
{
my($class, $type) = @_;

bless {
"DB" => undef,
"DB_type" => $type,
"DB_host" => undef,
"DB_port" => undef,
"DB_port" => undef,
"DB_username" => undef,
"lastSQL" => undef,
"version" => undef,
"sql_trace" => undef,
}, $class;
}


sub wacidConnectMySql
{
my($self, $database, $host, $port, $username, $password) = @_;

$self->{DB_name} = $database;
$self->{DB_host} = $host;
$self->{DB_port} = $port;
$self->{DB_username} = $username;

$datasource = "dbi:mysql:$database:$host:$port";

$self->{DB} = DBI->connect($datasource, $username, $password, { PrintError => 0})
|| &snort_error(&text('alert_err_connect_mysql', '<font color="red">'.$DBI::errstr.'</font>'));
print ref($self->{DB});
$self->{version} = $self->wacidDBGetVersionSchema;
}


Error: Function prepare not Defined

$self->{DB}->prepare($sql);

That I want to solve:

To be able refenrenciar to the object returned by the function DBI -> connect () across a variable of instance(authority) defined with the anonymous hash by function new()

Thank you .



Wink

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives