NAME
NTS::SqlLink - Front-end module to MySQL
DESCRIPTION
MySQL easy access
SYNOPSIS
#!/usr/bin/perl]
my ( @r , $c , $q , $i );
$c = new NTS::SqlLink({
'type' => 'mysql' ,
'db' => 'test' ,
'host' => 'localhost' ,
'username' => 'root' ,
'passwd' => '' ,
});
$q = "INSERT INTO test (id,name) VALUES (null,'user')" ;
$c -> do ( $q ); undef $q ;
$q = "SELECT id,name FROM test" ;
@r = $c -> return ( $q );
foreach $i ( @r ) {
print "ID: " . $i ->{id}. " - Name: " . $i ->{name}. "\n" ;
}
$c ->disconnect;
|
METHODS
new({type,db,host,username,passwd})
Create a new SqlLink object.
my $c = new NTS::SqlLink({
'type' => 'mysql' ,
'db' => 'test' ,
'host' => 'localhost' ,
'username' => 'root' ,
'passwd' => '' ,
});
|
$c->return(query)
only for select
@r = $c -> return ( $q );
foreach $i ( @r ) {
print "ID: " . $i ->{id}. " - Name: " . $i ->{name}. "\n" ;
}
|
$c->do(query)
to insert,update,replace,etc...
$q = "INSERT INTO test (id,name) VALUES (null,'user')" ;
$c -> do ( $q ); undef $q ;
|
$c->disconnect()
disconnect
$c ->disconnect();
|
$c->insertid()
$c->qt(string)
AddSlashes
$q = "INSERT INTO test (id,name) VALUES (null,'" . $c ->qt( $user ). "')" ;
|
Authors