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”;
}
Hot Tags: