Position:Home>web development> Perl operates the method of Mysql database
Perl operates the method of Mysql database
From;  Author:Stand originally
The Perl operation to MySQL.

One, standard operation

1, join, shut
My $dbh = DBI->connect(”DBI:mYsql:dAtabase=DBname;host=localhost” , ”user” , ”pwd” , {’RaiseError’=>1});
……
$dbh->disconnect();

2, similar insert etc without return an operation
My $sqr = $dbh->prepare(”insert Into Table_name(Name, region_id, inuse, url) Values (’” . $r_name. ”‘ , ’” . ($t 1) . ”‘ , ’1′ , ’” . $r_url. ”‘) “);
$sqr->execute();

3, obtain the ID that grows oneself

Carry out after inserting an operation
My $table_key = $dbh->{’mysql_insertid’};

4, Select operation
My $row;While ($row = $sqr->fetchrow_arrayref) {Printf $row->[0] . ” ” . $row->[1] . ”n”;
}



Previous:ASP mistake is solved: 800a003a mistake
Next:The account that Asp file cannot open