在下面加了点注释 颜色不一样
不知道你的基础怎么样 如果你会 PRO*C 或者 JAVA的 JDBC的话 
DBI的操作模式和PRO*C的 很像
跟JAVA 的JDBC 也还有点像
下面有蓝色的注释  你可以看以下 可能会对你有点儿帮助


--



在2009-08-21,"周延" [email protected]> 写道:
>
>刚接触这个,老师直接让改程序,语法粗看了下,下面这段还不懂但是时间又很紧,不能慢慢研究了,麻烦前辈们帮忙解答下,感激不尽^_^
>
>sub extract_person_list_from_database()
>{
>  my ($option, $total, $cid, $port) = @_;
>  my $sql_fetch_person = qq {select id, name from contact_info where
>issearch = 0 and id % ? = ? limit 20 };
>   #where 后面是什么意思啊?->我觉得这里你是不明白 后面两个?的意思 是在执行的时候提供变量替换  execute($total, $cid);

>  our $thedbh = &connect_database();
>  my $stat = $thedbh->prepare($sql_fetch_person);
>  my $sql_set_search = qq {update contact_info set issearch=1 where
>id=?};  #update是什么意思 -> UPDATE语句的作用你不明白的话 就应该去看看SQL了。。。。  更新DB
>  my $stat_set_search = $thedbh->prepare($sql_set_search);
>  my @current_array;
>  my $flag = 1;
>  my $rv;
>  my ($id, $name);   #这几行都是声明吗? ($id, $name);   为什么加括号 ->既然没有基础  那就记住 同时声明多个变量 
> 就加括号就好了
>  while ( $flag == 1 )
>  {
>     $rv = $stat->execute($total, $cid);
>     @current_array = ();
>     if( $rv > 0 )
>     {
>      $stat->bind_columns(\$id, \$name);   #这里也不知道?
-> 这里bind_columns(\$id, \$name); 用的是\$ 指针 可以理解成绑定 在下面 每次FETCH动作的时候 ID 和NAME 
的值就会发生相映的变化
>      while ( $stat->fetch())
>      {
>        push(@current_array, $id);
>        if( $option eq "ie")
>        {
>          &extract_person_with_IEGoogle($name, $id, $port);
>        }
>        else
>        {
>          &extract_person($name, $id);
>        }
>      }
>     }
>     else
>     {
>      $flag = 0;
>     }
>
>     foreach my $caid (@current_array)
>     {
>      $stat_set_search->execute($caid);
>     }
>  }
>  &disconnect_database($thedbh);
>}
>
>>

--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛“PerlChina Mongers 讨论组”论坛。
 要在此论坛发帖,请发电子邮件到 [email protected]
 要退订此论坛,请发邮件至 [email protected]
 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

回复