NAME

NTS::SqlLink - Front-end module to MySQL

DESCRIPTION

MySQL easy access

SYNOPSIS

#!/usr/bin/perl]
use strict;
my(@r,$c,$q,$i);
# Open DB
$c = new NTS::SqlLink({
'type' => 'mysql',
'db' => 'test',
'host' => 'localhost',
'username' => 'root',
'passwd' => '',
});
# Query Insert
$q = "INSERT INTO test (id,name) VALUES (null,'user')";
$c->do($q); undef $q;
# Query Select
$q = "SELECT id,name FROM test";
# Result
@r = $c->return($q);
foreach $i (@r) {
print "ID: ".$i->{id}." - Name: ".$i->{name}."\n";
}
# Close DB
$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()

return last insert id

$c->qt(string)

AddSlashes
$q = "INSERT INTO test (id,name) VALUES (null,'".$c->qt($user)."')";

Authors