package MyMysql; use strict; use DBI; sub new { my $class = shift; my $self = {} my $self->{db} = "mydatabase"; my $self->{host} = "localhost"; my $self->{user} = "root"; my $self->{dsn} = "DBI:mysql:$db:$host"; my $self->{attributes} = { PrintError => 0, RaiseError => 0 }; return bless $self, $class;} sub add_user(){ my $self=shift; my $self->{nickname} =$_[0]; my $self->{password} =$_[1]; my $self->{firstname} =$_[2]; my $self->{name} =$_[3]; my $self->{gender} =$_[4]; my $self->{birthdate} =$_[5]; my $self->{dbh} = DBI->connect($self->{dsn},$self->{user},undef, $self->{attributes}) or $self->WriteError('',"Error in connecting to $self->{dsn}", die => 1); ) $self->{nickname} = $dbh->quote($self->{nickname}); $slef->{password} = $dbh->quote($self->{password});}