RSS
热门关键字:
当前位置 :| 主页>web development>

Perl operates the method of Mysql database

来源: 作者:Stand originally 时间:2008-12-21 Tag: 点击:
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”;
}



最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
栏目列表
热点关注
相关文章