select.pl

来源:互联网 发布:淘宝秧歌服在哪儿买 编辑:程序博客网 时间:2024/06/04 19:04

#! /usr/bin/perl
#
use strict;
use DBI;
use DBI::DBD

open TMP,">>111";

my @row;
my $sql = "";
my $conn = "";
$conn = DBI->connect("DBI:mysql:database=lyytest:host=127.0.0.1","root","123456",{'RaiseError' => 1 });

$sql = $conn->prepare("select * from lyyinfo");
$sql->execute();

#$conn->do($sql);

while(my @row = $sql->fetchrow_array){
#while(@row = $conn->fetchrow()){  //错的
#while(@row = $conn->fetchrow_arr){ //错的
#while(@row = $conn->fetchrow_hashref){ //错的
  print TMP "$row[0], $row[1] , $row[2], $row[3], $row[4], $row[5]\n";
#  print TMP join(" ## ",@row),"\n";
}
//检查该条语句是否已经存在

my $sel = $conn->prepare("select * from lyyinfo");

$sel->execute();

if(my $ref = $sel->fetchrow_hashref()){

    print TMP "the database have this data\n";

}

else{

    print TMP "the database not have this data\n";

}

$sel->finish();

close TMP;
$conn->disconnect();

=================================================

 

原创粉丝点击