Home > Database > Mysql Tutorial > Perl操作mysql数据库的方法

Perl操作mysql数据库的方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:22:03
Original
1099 people have browsed it

Perl对Mysql的操作。 一、标准操作 1、连接、关闭 my $dbh = DBI-connect(DBI:mysql:database=DBname;host=localhost,user,pwd, {RaiseError = 1}); $dbh-disconnect(); 2、类似插入等无返回操作 my $sqr = $dbh-prepare(insert into table_name(Name,region

   Perl对Mysql的操作。

  一、标准操作

  1、连接、关闭

  my $dbh = DBI->connect(”DBI:mysql:database=DBname;host=localhost”,”user”,”pwd”, {’RaiseError’ => 1});

  … …

  $dbh->disconnect();

  2、类似插入等无返回操作

  my $sqr = $dbh->prepare(”insert into table_name(Name,region_id,inuse,url) values (’”.$r_name.”‘,’”.($t+1).”‘,’1′,’”.$r_url.”‘) “);

  $sqr->execute();

  3、取得自增长的ID

  执行插入操作后

  my $table_key = $dbh->{’mysql_insertid’};

  4、Select操作

  my $row;

  while ($row = $sqr->fetchrow_arrayref) {

  printf $row->[0].”++”.$row->[1].”n”;

  }

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template