Модераторы: korob2001, ginnie

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> проблема с Perl-овым скриптом 
:(
    Опции темы
allexeym
Дата 13.7.2007, 11:25 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 12
Регистрация: 13.7.2007

Репутация: нет
Всего: нет



сайт находится на хостинге, на котором наверное что-то изменили 

'это сказалось на работе сайта, который там хостица
а именно появилась проблема с выполнение перлового скрипта, который теперь выдаёт ошибку 
и не делает то что ему надо делать
вот ошибки

Код

Name "main::last_shop_id_arr" used only once: possible typo at ./make_index.pl line 30.
Name "main::last_shop_divid_arr" used only once: possible typo at ./make_index.pl line 33.
Name "main::shop_users_num" used only once: possible typo at ./make_index.pl line 167.
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at /usr/local/lib/perl5/site_perl/5.8.8/mach/Mysql/Statement.pm line 35.
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at /usr/local/lib/perl5/site_perl/5.8.8/mach/Mysql/Statement.pm line 35.
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at /usr/local/lib/perl5/site_perl/5.8.8/mach/Mysql/Statement.pm line 35.
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at /usr/local/lib/perl5/site_perl/5.8.8/mach/Mysql/Statement.pm line 35.
Use of uninitialized value in pattern match (m//) at ./make_index.pl line 38.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in pattern match (m//) at ./make_index.pl line 38.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in pattern match (m//) at ./make_index.pl line 38.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in pattern match (m//) at ./make_index.pl line 38.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in pattern match (m//) at ./make_index.pl line 38.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in pattern match (m//) at ./make_index.pl line 38.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
Use of uninitialized value in concatenation (.) or string at ./make_index.pl line 44.
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at /usr/local/lib/perl5/site_perl/5.8.8/mach/Mysql/Statement.pm line 35.
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at /usr/local/lib/perl5/site_perl/5.8.8/mach/Mysql/Statement.pm line 35.
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at /usr/local/lib/perl5/site_perl/5.8.8/mach/Mysql/Statement.pm line 35.
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at /usr/local/lib/perl5/site_perl/5.8.8/mach/Mysql/Statement.pm line 35.

всё, после этого скрипт висит

$perl -V
Код


Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=freebsd, osvers=5.5-release, archname=i386-freebsd-64int
    uname='freebsd tetis.uazone.net 5.5-release freebsd 5.5-release #0: mon nov 6 19:04:37 eet 2006 [email protected]:usrsrcsysi386compiletetis i386 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-O -pipe  -Ud_dosuid -Ui_gdbm -Dusethreads=n -Dusemymalloc=y -Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include',
    optimize='-O -pipe ',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
    ccversion='', gccversion='3.4.2 [FreeBSD] 20040728', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -Wl,-E -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lcrypt -lutil
    perllibs=-lm -lcrypt -lutil
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: MYMALLOC PERL_MALLOC_WRAP USE_64_BIT_INT
                        USE_LARGE_FILES USE_PERLIO
  Locally applied patches:
        defined-or
  Built under freebsd



$ mysql --version
mysql  Ver 14.7 Distrib 4.1.11, for portbld-freebsd4.4 (i386)


куда копать надо?
я так понимаю что нужно вносить изменения в скрипт 
но ХЗ какие:(

Добавлено @ 11:30

Добавлено через 8 минут и 56 секунд
вот сам скрипт 

Код

      8 $templ_dir="/usr/home/webshop/template";
      9 $home_dir="/usr/home/webshop/htdocs";
     10 $SHOP_IN_LAST=6;
     11
     12 use Mysql;
     13
     14 $dbh = Mysql->connect('*******', '******,'******', '******');
     15
     16 if(!$dbh){
     17   die "Error 0"
     18 }
     19
     20 #======================= Make catalog (rating) (catalog.html) ===================
     21
     22 $sth = $dbh->query("select Shop_ID,Shop_Name,Shop_SubDir,Div_ID,Aprove_Time from shop where Publish_St order by Aprove_Time desc");
     23
     24 if($sth==0){
     25   $error_message = $dbh->errmsg;
     28 }
     29
     30 @last_shop_id_arr=$sth->fetchcol(0);
     31 @last_shop_name_arr=$sth->fetchcol(1);
     32 @last_shop_subdir_arr=$sth->fetchcol(2);
     33 @last_shop_divid_arr=$sth->fetchcol(3);
     34 @last_shop_time_arr=$sth->fetchcol(4);
     35
     36 $last_str="";
     37 for($last_p_arr=0;$last_p_arr<$SHOP_IN_LAST;$last_p_arr++){
     38   if($last_shop_time_arr[$last_p_arr]=~/^(\d+)-(\d+)-(\d+)/){
     39     $year_99= $1; # % 100;
     40     $last_date_str="$3.$2.$year_99";
     41   }else{
     42     $last_date_str="";
     43   }
     45 }
     46
     47 $sth = $dbh->query("select Shop_ID,Shop_Name,Shop_SubDir,Show_Num,Div_ID from shop where Publish_St order by Shop_ID");
     48
     49 if($sth==0){
     50   $error_message = $dbh->errmsg;
     51   print STDERR "$error_message\n";
     52   die "Error in select";
     53 }
     54
     55 @shop_id_arr=();
     56 @shop_id_arr=$sth->fetchcol(0);
     57 @shop_name_arr=();
     58 @shop_name_arr=$sth->fetchcol(1);
     59 @shop_sd_arr=();
     60 @shop_sd_arr=$sth->fetchcol(2);
     61 @shop_n_arr=();
     62 @shop_n_arr=$sth->fetchcol(3);
     63 @shop_div_arr=();
     64 @shop_div_arr=$sth->fetchcol(4);
     65
     66 for($shop_p=0;$shop_p<=$#shop_id_arr;$shop_p++){
     67   $sth = $dbh->query("select count(*) from object where Shop_ID=$shop_id_arr[$shop_p] and Image_St");
     68   if($sth==0){
     69     $error_message = $dbh->errmsg;
     70     print STDERR "$error_message\n";
     71     die "Error in select";
     72   }
     73   $shop_obj_arr[$shop_p]=($sth->fetchrow)[0];
     74
     76   if($sth==0){
     77     $error_message = $dbh->errmsg;
     78     print STDERR "$error_message\n";
     79     die "Error in select";
     80   }
     81   $shop_week_arr[$shop_p]=($sth->fetchrow)[0];
     82
     83   $shop_r_id[$shop_p]=$shop_p;
     84 }
     85
     86 @shop_sort_id = sort shop_sort @shop_r_id;
     87
     88 #open(TEMPLATE,"$templ_dir/catalog.html") || die "(2) Can't Open catalog.html: $!\n";
     89 #
     90 #$publish_file=$home_dir."/catalog.html";
     91 #open(MAIN,">$publish_file") || die "(1) Can't Open $publish_file: $!\n";
     92 #W1:
     93 #while(<TEMPLATE>){
     94 #  if( /<shops>/ ){
     95 #    for($shop_p=0;$shop_p<=$#shop_sort_id;$shop_p++){
     96 #      &publish_shop_str($shop_sort_id[$shop_p]);
     97 #    }
     98 #    next W1;
     99 #  }
    100 #  print MAIN $_;
    101 #}
    102 #close(MAIN);
    103 #system("chmod 664 $publish_file");
    104 #close(TEMPLATE);
    105
    106 ########### ���� �� ��������� �������
    107 $max_list=($#shop_sort_id/20);
    108 for($p_c=0;$p_c<=$max_list;$p_c++){
    109   open(TEMPLATE,"$templ_dir/catalog.html") || die "(2) Can't Open catalog.html: $!\n";
    110
    111   $publish_file=page_enum_name($p_c,"$home_dir/catalog",0);
    112   $List_Navigation=make_List_Navigation($p_c,$max_list+1,$#shop_sort_id+1,"catalog",20);
    113   open(MAIN,">$publish_file") || die "(1) Can't Open $publish_file: $!\n";
    114   W1:
    115   while(<TEMPLATE>){
    116     if( /<shops>/ ){
    117       for($shop_p=$p_c*20; ($shop_p<=20+$p_c*20) && ($shop_p<$#shop_sort_id);$shop_p++){
    118         &publish_shop_str($shop_sort_id[$shop_p]);
    121     }
    122     s/<List_Navigation>/$List_Navigation/g;
    123     print MAIN $_;
    124   }
    125   close(MAIN);
    126   system("chmod 664 $publish_file");
    127   close(TEMPLATE);
    128
    129 }
    130
    131 #============================= Make main page (index.html) =====================
    132
    133 #================================= Find count value ============================
    134
    135 $sth = $dbh->query("select count(*) from shop");
    136 if($sth==0){
    137   $error_message = $dbh->errmsg;
    138   print STDERR "$error_message\n";
    139   die "Error in select";
    140 }
    141 $shop_num=($sth->fetchrow)[0];
    142
    143 $day=1;
    144
    145 $sth = $dbh->query("select count(*) from object where Image_St");
    146 if($sth==0){
    147   $error_message = $dbh->errmsg;
    148   print STDERR "$error_message\n";
    149   die "Error in select";
    150 }
    151 $all_obj_num=($sth->fetchrow)[0];
    152
    155   $error_message = $dbh->errmsg;
    156   print STDERR "$error_message\n";
    157   die "Error in select";
    160
    161 $sth = $dbh->query("select count(*) from show_log where Category_ID=0 and Object_ID=0 and to_days(now())-to_days(Show_Time)=$day");
    162 if($sth==0){
    163   $error_message = $dbh->errmsg;
    164   print STDERR "$error_message\n";
    165   die "Error in select";
    166 }
    167 $shop_users_num=($sth->fetchrow)[0];
    168
    170 if($sth==0){
    171   $error_message = $dbh->errmsg;
    172   print STDERR "$error_message\n";
    173   die "Error in select";
    174 }
    175 $obj_users_num=($sth->fetchrow)[0];
    176
    177 #========================== End of Find count value ============================
    178
    179 #========================== Make div ========================
    180
    181 $sth = $dbh->query("select Div_ID,Parent_Div,Div_Name from shop_div order by Sort_ID");
    182 if($sth==0){
    183   $error_message = $dbh->errmsg;
    184   print STDERR "$error_message\n";
    185   die "Error in select";
    186 }
    187 @d_id_arr=$sth->fetchcol(0);
    188 @d_par_arr=$sth->fetchcol(1);
    191 $d_id_arr[$#d_id_arr+1]="0";
    192 $d_par_arr[$#d_par_arr+1]="0";
    193 $d_name_arr[$#d_name_arr+1]="������";
    194
    195 $col_num=0;
    196 @col_body=("","");
    197 $pos=0;
    198 $all_pos=($#d_id_arr+1)*4;
    199 for($p_div=0;$p_div<=$#d_id_arr;$p_div++){
    200   $arrow="";
    201   if($p_div>0){
    203   }
    204   $arrow.="&nbsp;";
    205   if($p_div<$#d_id_arr){
    207   }
    208
    209   open(DIV_TEMPLATE,"$templ_dir/div.html") || die "(2) Can't Open $templ_dir/div.html: $!\n";
    210
    211   $publish_file=$home_dir."/div${d_id_arr[$p_div]}p0.html";
    212
    213   open(DIV,">$publish_file") || die "(1) Can't Open $publish_file: $!\n";
    214   $div_body="";
    215
    217   $div_shop_cnt=0;
    218   $pos++;
    219   for($ps_s=0;$ps_s<=$#shop_sort_id;$ps_s++){
    220     $p_s=$shop_sort_id[$ps_s];
    221     if($shop_div_arr[$p_s]==$d_id_arr[$p_div]){
    222        if($div_shop_cnt<3){
    223          if(length($shop_name_arr[$p_s])>20){
    224            $short_name=substr($shop_name_arr[$p_s],0,17);
    225            $short_name.="...";
    226          }else{
    227            $short_name=$shop_name_arr[$p_s];
    228          }
    229          $col_body[$col_num].="<a href=\"$shop_sd_arr[$p_s]/\">$short_name</a>\n";
    230          if($div_shop_cnt % 2){
    231            $col_body[$col_num].="<br>\n";
    232          }
    233          $pos++;
    234        }
    235        $div_shop_cnt++;
    237     }
    238   }
    239   $col_body[$col_num]=~s/<div_shop_cnt>/$div_shop_cnt/g;
    240
    241   $col_body[$col_num].="</font><br><br>\n";
    242
    243   if($div_shop_cnt<15){
    244     $div_add=15-$div_shop_cnt+3;
    245   }else{
    246     $div_add=3;
    247   }
    248   while($div_add>0){
    249     $div_body.="<br>";
    250     $div_add--;
    251   }
    252
    253   while(<DIV_TEMPLATE>){
    254
    255     s/<div_body>/$div_body/g;
    256     s/<div_name>/$d_name_arr[$p_div]/g;
    257     s/<div_shop_cnt>/$div_shop_cnt/g;
    258     s/<arrow>/$arrow/g;
    259
    260     print DIV $_;
    261   }
    262
    263   close(DIV);
    264   system("chmod 664 $publish_file");
    265   close(DIV_TEMPLATE);
    266
    267   if($col_num==0 && $pos>($all_pos)/2){
    268     $col_num=1;
    269   }
    270 }
    271
   


Добавлено через 10 минут и 13 секунд
part 2
Код

 272 ################
    273 # Make obj of day
    274 &obj_of_day_name;
    277
    278 open(TEMPLATE,"$templ_dir/index.html") || die "(2) Can't Open $templ_dir/index.html: $!\n";
    279
    280 $publish_file=$home_dir."/index.html";
    281 open(MAIN,">$publish_file") || die "(1) Can't Open $publish_file: $!\n";
    282
    283 while(<TEMPLATE>){
    284   s/<shop_num>/$shop_num/g;
    285   s/<all_obj_num>/$all_obj_num/g;
    286   s/<all_users_num>/$all_users_num/g;
    287   s/<obj_users_num>/$obj_users_num/g;
    288   s/<col1>/$col_body[0]/g;
    289   s/<col2>/$col_body[1]/g;
    290   s/<obj_day_name>/$obj_day_name/g;
    291   s/<obj_day_path>/$obj_day_path/g;
    292   s/<last_str>/$last_str/g;
    293
    294   print MAIN $_;
    295 }
    296
    297 close(MAIN);
    298 system("chmod 664 $publish_file");
    299 close(TEMPLATE);
    300
    301
    302 exit;
    303
    304 sub publish_shop_str{
    305   $arr_p=$_[0];
    306   open(SHOP,"$templ_dir/catalog_s.html") || die "(2) Can't Open catalog_s.html: $!\n";
    307   while(<SHOP>){
    308     s/<_name>/$shop_name_arr[$arr_p]/g;
    309     s/<obj_num>/$shop_obj_arr[$arr_p]/g;
    312     s/<subdir>/$shop_sd_arr[$arr_p]/g;
    313     print MAIN $_;
    314   }
    315   close(SHOP);
    316 }
    317
    318 sub shop_sort{
    319   $res=$shop_week_arr[$main::b] - $shop_week_arr[$main::a];
    320   return $res;
    321 }
    322
    323 sub obj_of_day_name{
    324    $day_id=&make_obj_of_day;
    326    if($sth==0){
    327      $error_message = $dbh->errmsg;
    328      print STDERR "$error_message\n";
    329      die "Error in select";
    330    }
    331    @obj_day_param=$sth->fetchrow;
    332    $obj_day_name=$obj_day_param[2].": ".$obj_day_param[0];
    333    $obj_day_shop=$obj_day_param[1];
    334    $sth = $dbh->query("select Shop_SubDir from shop where Shop_ID=$obj_day_shop");
    335    if($sth==0){
    336      $error_message = $dbh->errmsg;
    337      print STDERR "$error_message\n";
    338      die "Error in select";
    339    }
    340    $obj_subdir=($sth->fetchrow)[0];
    341    $obj_day_path=$obj_subdir."/obj_".$day_id.".html";
    342
    343 }
    344
    345 sub make_obj_of_day{
    346   $sth = $dbh->query("select Object_ID from obj_of_day where to_days(now())-to_days(Obj_Time)=0");
    347   if($sth==0){
    348     $error_message = $dbh->errmsg;
    349     print STDERR "$error_message\n";
    350     die "Error in select";
    351   }
    352   @dobj_arr=();
    353   @dobj_arr=$sth->fetchcol(0);
    354   if($#dobj_arr>=0){
    355     $obj_of_day_id=$dobj_arr[0];
    356     return $obj_of_day_id;
    357   }
    358
    360   if($sth==0){
    361     $error_message = $dbh->errmsg;
    362     print STDERR "$error_message\n";
    363     die "Error in select";
    364   }
    365
    366   @dobj_id_arr=();
    367   @dobj_id_arr=$sth->fetchcol(0);
    368   @dobj_show_arr=();
    369   @dobj_show_arr=$sth->fetchcol(1);
    370
    371   for($obj_p=0;$obj_p<=$#dobj_id_arr;$obj_p++){
    372     $obj_r_id[$obj_p]=$obj_p;
    373   }
    374
    375   @obj_sort_id = sort obj_sort @obj_r_id;
    376
    377   $end=0;
    378   $po=0;
    379   while($end==0){
    380     $obj_posbl_id = $dobj_id_arr[$obj_sort_id[$po]];
    381     if($obj_posbl_id eq ""){
    382         $obj_posbl_id = 1499;
    383     }
    384     $sth = $dbh->query("select Object_ID from obj_of_day where to_days(now())-to_days(Obj_Time)<7 and Object_ID=$obj_posbl_id");
    385     if($sth==0){
    386       $error_message = $dbh->errmsg;
    387       print STDERR "$error_message\n";
    388       die "Error in select";
    389     }
    390     @found_id_arr=();
    391     @found_id_arr=$sth->fetchcol(0);
    392     if($#found_id_arr<0){
    393       $end=1;
    394     }else{
    395       $po++;
    396       if($po>$#obj_sort_id){
    397         $end=1;
    398       }
    399     }
    400   }
    401   if($po<=$#obj_sort_id){
    402     $obj_of_day_id=$dobj_id_arr[$obj_sort_id[$po]];
    403     $obj_show_num=$dobj_show_arr[$obj_sort_id[$po]];
    404   }else{
    405     $obj_of_day_id=$dobj_id_arr[$obj_sort_id[0]];
    406     $obj_show_num=$dobj_show_arr[$obj_sort_id[0]];
    407   }
    


Это сообщение отредактировал(а) allexeym - 13.7.2007, 11:33
PM MAIL   Вверх
fantome
Дата 13.7.2007, 11:39 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 77
Регистрация: 5.2.2007

Репутация: 1
Всего: 1



allexeym
так тебе ж в ошипках все написали....
у тебя используются неинициализированные значения да и к БД ты не обращаешься... подключился к ней, сформировал запрос... И без его выполнения пытаешься получить данные...

Если немного в перле понимаешь, то man DBI...


Это сообщение отредактировал(а) fantome - 13.7.2007, 11:40
PM MAIL   Вверх
allexeym
Дата 13.7.2007, 11:40 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 12
Регистрация: 13.7.2007

Репутация: нет
Всего: нет



PS

до конца скрипт выожить не могу
ругается на большое сообщение

Добавлено через 4 минуты и 26 секунд
>Если немного в перле понимаешь, то man DBI...

в перле вообще 0 :(

а что же нужно изменить?
и раньше ведь работало с этим скриптом

PM MAIL   Вверх
fantome
Дата 13.7.2007, 11:49 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 77
Регистрация: 5.2.2007

Репутация: 1
Всего: 1



allexeym
чтобы понять, что изменять - надо скрипт полностью увидеть и получить описание того, что он должен делать...

ну и желательно список перловых модулей, которые есть в системе....


Это сообщение отредактировал(а) fantome - 13.7.2007, 11:54
PM MAIL   Вверх
allexeym
Дата 13.7.2007, 11:58 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 12
Регистрация: 13.7.2007

Репутация: нет
Всего: нет



вот весь скрипт, от начала до конца

http://www.it-m.kiev.ua/files/make_index.txt

Добавлено через 7 минут и 53 секунды
>ну и желательно список перловых модулей, которые есть в системе....


$ pkg_info | grep perl
Код

bsdpan-Bit-Vector-6.4 Unknown perl module
bsdpan-CPAN-1.76    CPAN - query, download and build perl modules from CPAN sit
bsdpan-CPAN-1.8801  CPAN - query, download and build perl modules from CPAN sit
bsdpan-CPAN-1.8802  CPAN - query, download and build perl modules from CPAN sit
bsdpan-Carp-Clan-5.8 Unknown perl module
bsdpan-Data-Dumper-2.121 Data::Dumper - stringified perl data structures, suitable f
bsdpan-Date-Calc-5.4 Unknown perl module
bsdpan-Date-Manip-5.42 Unknown perl module
bsdpan-Log-Log4perl-1.08 Log::Log4perl - Log4j implementation for Perl
bsdpan-Parse-RecDescent-1.94 Unknown perl module
bsdpan-Pod-Simple-3.04 Unknown perl module
bsdpan-Term-ReadLine-Perl-1.0203 Unknown perl module
bsdpan-Term-ReadLine-Perl-1.0302 Unknown perl module
bsdpan-TermReadKey-2.30 Term::ReadKey - A perl module for simple terminal control
bsdpan-libwww-perl-5.803 LWP - The World-Wide Web library for Perl
p5-DBI-137-1.37     The perl5 Database Interface.  Required for DBD::* modules
p5-GD-2.07          A perl5 interface to Gd Graphics Library version2
p5-MIME-Tools-5.410 A set of perl5 modules for MIME
p5-Scalar-List-Utils-1.18,1 Perl subroutines that would be nice to have in the perl cor
p5-Test-Harness-2.64 Run perl standard test scripts with statistics
p5-Test-Simple-0.64 Basic utilities for writing tests in perl
p5-Time-HiRes-01.20 A perl5 module implementing High resolution time, sleep, an
perl-5.6.2_2        Practical Extraction and Report Language
perl-5.8.6_2        Practical Extraction and Report Language
perl-5.8.8          Practical Extraction and Report Language


PM MAIL   Вверх
nitr
Дата 13.7.2007, 12:23 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Участник Клуба
Сообщений: 2543
Регистрация: 10.2.2006
Где: Россия :)

Репутация: 37
Всего: 84



allexeym, уже где-то на форуме описывалась такая проблема - решение использовать модуль use DBI;, + установить драйвер DBD::mysql.

Попросите админов хостинга установить, хотя думаю, что уже давно там он есть...


--------------------
PM   Вверх
allexeym
Дата 13.7.2007, 12:39 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 12
Регистрация: 13.7.2007

Репутация: нет
Всего: нет



драйвер DBD::mysql  установлен 

а как использовать модуль use DBI?
PM MAIL   Вверх
allexeym
Дата 13.7.2007, 13:18 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 12
Регистрация: 13.7.2007

Репутация: нет
Всего: нет



немного разобрался в принципе работы этого DBI

внёс такие вот изменения 
Код


use DBI;
$dbh = DBI->connect( 'DBI:mysql:webshop:localhost','db_name', 'pass');


тепрь вываливается с ошибкой 

Код

Name "main::last_shop_id_arr" used only once: possible typo at ./make_index.pl line 28.
Name "main::last_shop_divid_arr" used only once: possible typo at ./make_index.pl line 31.
Name "main::shop_users_num" used only once: possible typo at ./make_index.pl line 165.
Can't locate object method "query" via package "DBI::db" at ./make_index.pl line 20. 



PM MAIL   Вверх
nitr
Дата 13.7.2007, 13:31 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Участник Клуба
Сообщений: 2543
Регистрация: 10.2.2006
Где: Россия :)

Репутация: 37
Всего: 84



allexeym, модуль только ПОХОЖ на тот что использовали!!! Он иной!!!

т.е. методы того, не идентичны smile

Цитата
DBD::mysql - MySQL driver for the Perl5 Database Interface

NAME

DBD::mysql - MySQL driver for the Perl5 Database Interface (DBI)

SYNOPSIS

    use DBI;
    $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
    $dbh = DBI->connect($dsn, $user, $password);
    $drh = DBI->install_driver("mysql");

    @databases = DBI->data_sources("mysql");
       or
    @databases = DBI->data_sources("mysql",
                                   {"host" => $host, "port" => $port});

    $sth = $dbh->prepare("SELECT * FROM foo WHERE bla");
       or
    $sth = $dbh->prepare("LISTFIELDS $table");
       or
    $sth = $dbh->prepare("LISTINDEX $table $index");
    $sth->execute;
    $numRows = $sth->rows;
    $numFields = $sth->{'NUM_OF_FIELDS'};
    $sth->finish;

    $rc = $drh->func('createdb', $database, $host, $user, $password, 'admin');
    $rc = $drh->func('dropdb', $database, $host, $user, $password, 'admin');
    $rc = $drh->func('shutdown', $host, $user, $password, 'admin');
    $rc = $drh->func('reload', $host, $user, $password, 'admin');

    $rc = $dbh->func('createdb', $database, 'admin');
    $rc = $dbh->func('dropdb', $database, 'admin');
    $rc = $dbh->func('shutdown', 'admin');
    $rc = $dbh->func('reload', 'admin');

EXAMPLE

  #!/usr/bin/perl

  use strict;
  use DBI();

  # Connect to the database.
  my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost",
                         "joe", "joe's password",
                         {'RaiseError' => 1});

  # Drop table 'foo'. This may fail, if 'foo' doesn't exist.
  # Thus we put an eval around it.
  eval { $dbh->do("DROP TABLE foo") };
  print "Dropping foo failed: $@\n" if $@;

  # Create a new table 'foo'. This must not fail, thus we don't
  # catch errors.
  $dbh->do("CREATE TABLE foo (id INTEGER, name VARCHAR(20))");

  # INSERT some data into 'foo'. We are using $dbh->quote() for
  # quoting the name.
  $dbh->do("INSERT INTO foo VALUES (1, " . $dbh->quote("Tim") . ")");

  # Same thing, but using placeholders
  $dbh->do("INSERT INTO foo VALUES (?, ?)", undef, 2, "Jochen");

  # Now retrieve data from the table.
  my $sth = $dbh->prepare("SELECT * FROM foo");
  $sth->execute();
  while (my $ref = $sth->fetchrow_hashref()) {
    print "Found a row: id = $ref->{'id'}, name = $ref->{'name'}\n";
  }
  $sth->finish();

  # Disconnect from the database.
  $dbh->disconnect();

DESCRIPTION

DBD::mysql is the Perl5 Database Interface driver for the MySQL database. In other words: DBD::mysql is an interface between the Perl programming language and the MySQL programming API that comes with the MySQL relational database management system. Most functions provided by this programming API are supported. Some rarely used functions are missing, mainly because noone ever requested them. smile

In what follows we first discuss the use of DBD::mysql, because this is what you will need the most. For installation, see the sections on INSTALLATION, and WIN32 INSTALLATION below. See EXAMPLE for a simple example above.

From perl you activate the interface with the statement

    use DBI;

After that you can connect to multiple MySQL database servers and send multiple queries to any of them via a simple object oriented interface. Two types of objects are available: database handles and statement handles. Perl returns a database handle to the connect method like so:

  $dbh = DBI->connect("DBI:mysql:database=$db;host=$host",
                      $user, $password, {RaiseError => 1});

Once you have connected to a database, you can can execute SQL statements with:

  my $query = sprintf("INSERT INTO foo VALUES (%d, %s)",
                      $number, $dbh->quote("name"));
  $dbh->do($query);

See DBI(3) for details on the quote and do methods. An alternative approach is

  $dbh->do("INSERT INTO foo VALUES (?, ?)", undef,
           $number, $name);

in which case the quote method is executed automatically. See also the bind_param method in DBI(3). See DATABASE HANDLES below for more details on database handles.

If you want to retrieve results, you need to create a so-called statement handle with:

  $sth = $dbh->prepare("SELECT * FROM $table");
  $sth->execute();

This statement handle can be used for multiple things. First of all you can retreive a row of data:

  my $row = $sth->fetchow_hashref();

If your table has columns ID and NAME, then $row will be hash ref with keys ID and NAME. See STATEMENT HANDLES below for more details on statement handles.

But now for a more formal approach:

Class Methods

connect

        use DBI;

        $dsn = "DBI:mysql:$database";
        $dsn = "DBI:mysql:database=$database;host=$hostname";
        $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";

        $dbh = DBI->connect($dsn, $user, $password);

    A database must always be specified.

host
port

    The hostname, if not specified or specified as '', will default to an MySQL daemon running on the local machine on the default port for the UNIX socket.

    Should the MySQL daemon be running on a non-standard port number, you may explicitly state the port number to connect to in the hostname argument, by concatenating the hostname and port number together separated by a colon ( : ) character or by using the port argument.
mysql_client_found_rows

    Enables (TRUE value) or disables (FALSE value) the flag CLIENT_FOUND_ROWS while connecting to the MySQL server. This has a somewhat funny effect: Without mysql_client_found_rows, if you perform a query like

      UPDATE $table SET id = 1 WHERE id = 1

    then the MySQL engine will always return 0, because no rows have changed. With mysql_client_found_rows however, it will return the number of rows that have an id 1, as some people are expecting. (At least for compatibility to other engines.)
mysql_compression

    As of MySQL 3.22.3, a new feature is supported: If your DSN contains the option ``mysql_compression=1'', then the communication between client and server will be compressed.
mysql_connect_timeout

    If your DSN contains the option ``mysql_connect_timeout=##'', the connect request to the server will timeout if it has not been successful after the given number of seconds.
mysql_read_default_file
mysql_read_default_group

    These options can be used to read a config file like /etc/my.cnf or ~/.my.cnf. By default MySQL's C client library doesn't use any config files unlike the client programs (mysql, mysqladmin, ...) that do, but outside of the C client library. Thus you need to explicitly request reading a config file, as in

        $dsn = "DBI:mysql:test;mysql_read_default_file=/home/joe/my.cnf";
        $dbh = DBI->connect($dsn, $user, $password)

    The option mysql_read_default_group can be used to specify the default group in the config file: Usually this is the client group, but see the following example:

        [client]
        host=localhost

        [perl]
        host=perlhost

    (Note the order of the entries! The example won't work, if you reverse the [client] and [perl] sections!)

    If you read this config file, then you'll be typically connected to localhost. However, by using

        $dsn = "DBI:mysql:test;mysql_read_default_group=perl;"
            . "mysql_read_default_file=/home/joe/my.cnf";
        $dbh = DBI->connect($dsn, $user, $password);

    you'll be connected to perlhost. Note that if you specify a default group and do not specify a file, then the default config files will all be read. See the documentation of the C function mysql_options() for details.
mysql_socket

    As of MySQL 3.21.15, it is possible to choose the Unix socket that is used for connecting to the server. This is done, for example, with

        mysql_socket=/dev/mysql

    Usually there's no need for this option, unless you are using another location for the socket than that built into the client.
mysql_ssl

    A true value turns on the CLIENT_SSL flag when connecting to the MySQL database:

      mysql_ssl=1

    This means that your communication with the server will be encrypted.

    If you turn mysql_ssl on, you might also wish to use the following flags:
mysql_ssl_client_key
mysql_ssl_client_cert
mysql_ssl_ca_file
mysql_ssl_ca_path
mysql_ssl_cipher

    These are used to specify the respective parameters of a call to mysql_ssl_set, if mysql_ssl is turned on.
mysql_local_infile

    As of MySQL 3.23.49, the LOCAL capability for LOAD DATA may be disabled in the MySQL client library by default. If your DSN contains the option ``mysql_local_infile=1'', LOAD DATA LOCAL will be enabled. (However, this option is *ineffective* if the server has also been configured to disallow LOCAL.)
Prepared statement support (server side prepare)

    To use server side prepared statements, all you need to do is set the variable mysql_server_prepare in the connect:

    $dbh = DBI->connect( ``DBI:mysql:database=test;host=localhost:mysql_server_prepare=1'', ``'', ``'', { RaiseError => 1, AutoCommit => 1 } );

    To make sure that the 'make test' step tests whether server prepare works, you just need to export the env variable MYSQL_SERVER_PREPARE:

    export MYSQL_SERVER_PREPARE=1

    Test first without server side prepare, then with.
mysql_embedded_options

    The option <mysql_embedded_options> can be used to pass 'command-line' options to embedded server.

    Example:

    $testdsn=``DBI:mysqlEmb:database=test;mysql_embedded_options=--help,--verbose'';
mysql_embedded_groups

    The option <mysql_embedded_groups> can be used to specify the groups in the config file(my.cnf) which will be used to get options for embedded server. If not specified [server] and [embedded] groups will be used.

    Example:

    $testdsn=``DBI:mysqlEmb:database=test;mysql_embedded_groups=embedded_server,common'';

Private MetaData Methods

ListDBs

        my $drh = DBI->install_driver("mysql");
        @dbs = $drh->func("$hostname:$port", '_ListDBs');
        @dbs = $drh->func($hostname, $port, '_ListDBs');
        @dbs = $dbh->func('_ListDBs');

    Returns a list of all databases managed by the MySQL daemon running on $hostname, port $port. This method is rarely needed for databases running on localhost: You should use the portable method

        @dbs = DBI->data_sources("mysql");

    whenever possible. It is a design problem of this method, that there's no way of supplying a host name or port number to data_sources, that's the only reason why we still support ListDBs. :-(

Server Administration

admin

        $rc = $drh->func("createdb", $dbname, [host, user, password,], 'admin');
        $rc = $drh->func("dropdb", $dbname, [host, user, password,], 'admin');
        $rc = $drh->func("shutdown", [host, user, password,], 'admin');
        $rc = $drh->func("reload", [host, user, password,], 'admin');

          or

        $rc = $dbh->func("createdb", $dbname, 'admin');
        $rc = $dbh->func("dropdb", $dbname, 'admin');
        $rc = $dbh->func("shutdown", 'admin');
        $rc = $dbh->func("reload", 'admin');

    For server administration you need a server connection. For obtaining this connection you have two options: Either use a driver handle (drh) and supply the appropriate arguments (host, defaults localhost, user, defaults to '' and password, defaults to ''). A driver handle can be obtained with

        $drh = DBI->install_driver('mysql');

    Otherwise reuse the existing connection of a database handle (dbh).

    There's only one function available for administrative purposes, comparable to the m(y)sqladmin programs. The command being execute depends on the first argument:

createdb

    Creates the database $dbname. Equivalent to ``m(y)sqladmin create $dbname''.
dropdb

    Drops the database $dbname. Equivalent to ``m(y)sqladmin drop $dbname''.

    It should be noted that database deletion is not prompted for in any way. Nor is it undo-able from DBI.

        Once you issue the dropDB() method, the database will be gone!

    These method should be used at your own risk.
shutdown

    Silently shuts down the database engine. (Without prompting!) Equivalent to ``m(y)sqladmin shutdown''.
reload

    Reloads the servers configuration files and/or tables. This can be particularly important if you modify access privileges or create new users.

DATABASE HANDLES

The DBD::mysql driver supports the following attributes of database handles (read only):

  $errno = $dbh->{'mysql_errno'};
  $error = $dbh->{'mysql_error};
  $info = $dbh->{'mysql_hostinfo'};
  $info = $dbh->{'mysql_info'};
  $insertid = $dbh->{'mysql_insertid'};
  $info = $dbh->{'mysql_protoinfo'};
  $info = $dbh->{'mysql_serverinfo'};
  $info = $dbh->{'mysql_stat'};
  $threadId = $dbh->{'mysql_thread_id'};
  

These correspond to mysql_errno(), mysql_error(), mysql_get_host_info(), mysql_info(), mysql_insert_id(), mysql_get_proto_info(), mysql_get_server_info(), mysql_stat() and mysql_thread_id(), respectively.

 $info_hashref = $dhb->{mysql_dbd_stats}

DBD::mysql keeps track of some statistics in the mysql_dbd_stats attribute. The following stats are being maintained:

auto_reconnects_ok

    The number of times that DBD::mysql successfully reconnected to the mysql server.
auto_reconnects_failed

    The number of times that DBD::mysql tried to reconnect to mysql but failed.

The DBD::mysql driver also supports the following attribute(s) of database handles (read/write):

 $bool_value = $dbh->{mysql_auto_reconnect};
 $dbh->{mysql_auto_reconnect} = $AutoReconnect ? 1 : 0;

mysql_auto_reconnect

    This attribute determines whether DBD::mysql will automatically reconnect to mysql if the connection be lost. This feature defaults to off; however, if either the GATEWAY_INTERFACE or MOD_PERL envionment variable is set, DBD::mysql will turn mysql_auto_reconnect on. Setting mysql_auto_reconnect to on is not advised if 'lock tables' is used because if DBD::mysql reconnect to mysql all table locks will be lost. This attribute is ignored when AutoCommit is turned off, and when AutoCommit is turned off, DBD::mysql will not automatically reconnect to the server.
mysql_use_result

    This attribute forces the driver to use mysql_use_result rather than mysql_store_result. The former is faster and less memory consuming, but tends to block other processes. (That's why mysql_store_result is the default.)

    It is possible to set default value of the mysql_use_result attribute for $dbh using several ways:

     - through DSN

       $dbh= DBI->connect("DBI:mysql:test;mysql_use_result=1", "root", "");

     - after creation of database handle

       $dbh->{'mysql_use_result'}=0; #disable
       $dbh->{'mysql_use_result'}=1; #enable

    It is possible to set/unset the mysql_use_result attribute after creation of statement handle. See below.

STATEMENT HANDLES

The statement handles of DBD::mysql support a number of attributes. You access these by using, for example,

  my $numFields = $sth->{'NUM_OF_FIELDS'};

Note, that most attributes are valid only after a successfull execute. An undef value will returned in that case. The most important exception is the mysql_use_result attribute: This forces the driver to use mysql_use_result rather than mysql_store_result. The former is faster and less memory consuming, but tends to block other processes. (That's why mysql_store_result is the default.)

To set the mysql_use_result attribute, use either of the following:

  my $sth = $dbh->prepare("QUERY", { "mysql_use_result" => 1});

or

  my $sth = $dbh->prepare("QUERY");
  $sth->{"mysql_use_result"} = 1;

Column dependent attributes, for example NAME, the column names, are returned as a reference to an array. The array indices are corresponding to the indices of the arrays returned by fetchrow and similar methods. For example the following code will print a header of table names together with all rows:

  my $sth = $dbh->prepare("SELECT * FROM $table");
  if (!$sth) {
      die "Error:" . $dbh->errstr . "\n";
  }
  if (!$sth->execute) {
      die "Error:" . $sth->errstr . "\n";
  }
  my $names = $sth->{'NAME'};
  my $numFields = $sth->{'NUM_OF_FIELDS'};
  for (my $i = 0;  $i < $numFields;  $i++) {
      printf("%s%s", $i ? "," : "", $$names[$i]);
  }
  print "\n";
  while (my $ref = $sth->fetchrow_arrayref) {
      for (my $i = 0;  $i < $numFields;  $i++) {
          printf("%s%s", $i ? "," : "", $$ref[$i]);
      }
      print "\n";
  }

For portable applications you should restrict yourself to attributes with capitalized or mixed case names. Lower case attribute names are private to DBD::mysql. The attribute list includes:

ChopBlanks

    this attribute determines whether a fetchrow will chop preceding and trailing blanks off the column values. Chopping blanks does not have impact on the max_length attribute.
mysql_insertid

    MySQL has the ability to choose unique key values automatically. If this happened, the new ID will be stored in this attribute. An alternative way for accessing this attribute is via $dbh->{'mysql_insertid'}. (Note we are using the $dbh in this case!)
mysql_is_blob

    Reference to an array of boolean values; TRUE indicates, that the respective column is a blob. This attribute is valid for MySQL only.
mysql_is_key

    Reference to an array of boolean values; TRUE indicates, that the respective column is a key. This is valid for MySQL only.
mysql_is_num

    Reference to an array of boolean values; TRUE indicates, that the respective column contains numeric values.
mysql_is_pri_key

    Reference to an array of boolean values; TRUE indicates, that the respective column is a primary key.
mysql_is_auto_increment

    Reference to an array of boolean values; TRUE indicates that the respective column is an AUTO_INCREMENT column. This is only valid for MySQL.
mysql_length
mysql_max_length

    A reference to an array of maximum column sizes. The max_length is the maximum physically present in the result table, length gives the theoretically possible maximum. max_length is valid for MySQL only.
NAME

    A reference to an array of column names.
NULLABLE

    A reference to an array of boolean values; TRUE indicates that this column may contain NULL's.
NUM_OF_FIELDS

    Number of fields returned by a SELECT or LISTFIELDS statement. You may use this for checking whether a statement returned a result: A zero value indicates a non-SELECT statement like INSERT, DELETE or UPDATE.
mysql_table

    A reference to an array of table names, useful in a JOIN result.
TYPE

    A reference to an array of column types. The engine's native column types are mapped to portable types like DBI::SQL_INTEGER() or DBI::SQL_VARCHAR(), as good as possible. Not all native types have a meaningfull equivalent, for example DBD::mysql::FIELD_TYPE_INTERVAL is mapped to DBI::SQL_VARCHAR(). If you need the native column types, use mysql_type. See below.
mysql_type

    A reference to an array of MySQL's native column types, for example DBD::mysql::FIELD_TYPE_SHORT() or DBD::mysql::FIELD_TYPE_STRING(). Use the TYPE attribute, if you want portable types like DBI::SQL_SMALLINT() or DBI::SQL_VARCHAR().
mysql_type_name

    Similar to mysql, but type names and not numbers are returned. Whenever possible, the ANSI SQL name is preferred.

TRANSACTION SUPPORT

Beginning with DBD::mysql 2.0416, transactions are supported. The transaction support works as follows:

    *

      By default AutoCommit mode is on, following the DBI specifications.
    *

      If you execute

          $dbh->{'AutoCommit'} = 0;

      or

          $dbh->{'AutoCommit'} = 1;

      then the driver will set the MySQL server variable autocommit to 0 or 1, respectively. Switching from 0 to 1 will also issue a COMMIT, following the DBI specifications.
    *

      The methods

          $dbh->rollback();
          $dbh->commit();

      will issue the commands COMMIT and ROLLBACK, respectively. A ROLLBACK will also be issued if AutoCommit mode is off and the database handles DESTROY method is called. Again, this is following the DBI specifications.

Given the above, you should note the following:

    *

      You should never change the server variable autocommit manually, unless you are ignoring DBI's transaction support.
    *

      Switching AutoCommit mode from on to off or vice versa may fail. You should always check for errors, when changing AutoCommit mode. The suggested way of doing so is using the DBI flag RaiseError. If you don't like RaiseError, you have to use code like the following:

        $dbh->{'AutoCommit'} = 0;
        if ($dbh->{'AutoCommit'}) {
          # An error occurred!
        }

    *

      If you detect an error while changing the AutoCommit mode, you should no longer use the database handle. In other words, you should disconnect and reconnect again, because the transaction mode is unpredictable. Alternatively you may verify the transaction mode by checking the value of the server variable autocommit. However, such behaviour isn't portable.
    *

      DBD::mysql has a ``reconnect'' feature that handles the so-called MySQL ``morning bug'': If the server has disconnected, most probably due to a timeout, then by default the driver will reconnect and attempt to execute the same SQL statement again. However, this behaviour is disabled when AutoCommit is off: Otherwise the transaction state would be completely unpredictable after a reconnect.
    *

      The ``reconnect'' feature of DBD::mysql can be toggled by using the mysql_auto_reconnect attribute. This behaviour should be turned off in code that uses LOCK TABLE because if the database server time out and DBD::mysql reconnect, table locks will be lost without any indication of such loss.

SQL EXTENSIONS

Certain metadata functions of MySQL that are available on the C API level, haven't been implemented here. Instead they are implemented as ``SQL extensions'' because they return in fact nothing else but the equivalent of a statement handle. These are:

LISTFIELDS $table

    Returns a statement handle that describes the columns of $table. Ses the docs of mysql_list_fields (C API) for details.

COMPATIBILITY ALERT

The statement attribute TYPE has changed its meaning, as of DBD::mysql 2.0119. Formerly it used to be the an array of native engine's column types, but it is now an array of portable SQL column types. The old attribute is still available as mysql_type.

DBD::mysql is a moving target, due to a number of reasons:

-

    Of course we have to conform the DBI guidelines and developments.
-

    We have to keep track with the latest MySQL developments.
-

    And, surprisingly, we have to be as close to ODBC as possible: This is due to the current direction of DBI.
-

    And, last not least, as any tool it has a little bit life of its own.

This means that a lot of things had to and have to be changed. As I am not interested in maintaining a lot of compatibility kludges, which only increase the drivers code without being really usefull, I did and will remove some features, methods or attributes.

To ensure a smooth upgrade, the following policy will be applied:

Obsolete features

    The first step is to declare something obsolete. This means, that no code is changed, but the feature appears in the list of obsolete features. See Obsolete Features below.
Deprecated features

    If the feature has been obsolete for quite some time, typically in the next major stable release, warnings will be inserted in the code. You can suppress these warnings by setting

        $DBD::mysql = 1;

    In the docs the feature will be moved from the list of obsolete features to the list of deprecated features. See Deprecated Features below.
Removing features

    Finally features will be removed silently in the next major stable release. The feature will be shown in the list of historic features. See Historic Features below.

Example: The statement handle attribute

    $sth->{'LENGTH'}

was declared obsolete in DBD::mysql 2.00xy. It was considered deprecated in DBD::mysql 2.02xy and removed in 2.04xy.

Obsolete Features

Database handle attributes

    The following database handle attributes are declared obsolete in DBD::mysql 2.09. They will be deprecated in 2.11 and removed in 2.13.

$dbh-{'errno'}>

    Replaced by $dbh-{'mysql_errno'}>
$dbh-{'errmsg'}>

    Replaced by $dbh-{'mysql_error'}>
$dbh-{'hostinfo'}>

    Replaced by $dbh-{'mysql_hostinfo'}>
$dbh-{'info'}>

    Replaced by $dbh-{'mysql_info'}>
$dbh-{'protoinfo'}>

    Replaced by $dbh-{'mysql_protoinfo'}>
$dbh-{'serverinfo'}>

    Replaced by $dbh-{'mysql_serverinfo'}>
$dbh-{'stats'}>

    Replaced by $dbh-{'mysql_stat'}>
$dbh-{'thread_id'}>

    Replaced by $dbh-{'mysql_thread_id'}>

Deprecated Features

_ListTables

    Replace with the standard DBI method $dbh-tables()>. See also $dbh-table_info()>. Portable applications will prefer

        @tables = map { $_ =~ s/.*\.//; $_ } $dbh->tables()

    because, depending on the engine, the string ``user.table'' will be returned, user being the table owner. The method will be removed in DBD::mysql version 2.11xy.

Historic Features

_CreateDB
_DropDB

    The methods

        $dbh->func($db, '_CreateDB');
        $dbh->func($db, '_DropDB');

    have been used for creating or dropping databases. They have been removed in 1.21_07 in favour of

        $drh->func("createdb", $dbname, $host, "admin")
        $drh->func("dropdb", $dbname, $host, "admin")

_ListFields

    The method

        $sth = $dbh->func($table, '_ListFields');

    has been used to list a tables columns names, types and other attributes. This method has been removed in 1.21_07 in favour of

        $sth = $dbh->prepare("LISTFIELDS $table");

_ListSelectedFields

    The method

        $sth->func('_ListSelectedFields');

    use to return a hash ref of attributes like 'IS_NUM', 'IS_KEY' and so on. These attributes are now accessible via

        $sth->{'mysql_is_num'};
        $sth->{'mysql_is_key'};

    and so on. Thus the method has been removed in 1.21_07.
_NumRows

    The method

        $sth->func('_NumRows');

    used to be equivalent to

        $sth->rows();

    and has been removed in 1.21_07.
_InsertID

    The method

        $dbh->func('_InsertID');

    used to be equivalent with

        $dbh->{'mysql_insertid'};

Statement handle attributes

affected_rows

    Replaced with $sth->{'mysql_affected_rows'} or the result of $sth->execute().
format_default_size

    Replaced with $sth->{'PRECISION'}.
format_max_size

    Replaced with $sth->{'mysql_max_length'}.
format_type_name

    Replaced with $sth->{'TYPE'} (portable) or $sth->{'mysql_type_name'} (MySQL specific).
format_right_justify

    Replaced with $sth->->{'TYPE'} (portable) or $sth->{'mysql_is_num'} (MySQL specific).
insertid

    Replaced with $sth->{'mysql_insertid'}.
IS_BLOB

    Replaced with $sth->{'TYPE'} (portable) or $sth->{'mysql_is_blob'} (MySQL specific).
is_blob

    Replaced with $sth->{'TYPE'} (portable) or $sth->{'mysql_is_blob'} (MySQL specific).
IS_PRI_KEY

    Replaced with $sth->{'mysql_is_pri_key'}.
is_pri_key

    Replaced with $sth->{'mysql_is_pri_key'}.
IS_NOT_NULL

    Replaced with $sth->{'NULLABLE'} (do not forget to invert the boolean values).
is_not_null

    Replaced with $sth->{'NULLABLE'} (do not forget to invert the boolean values).
IS_NUM

    Replaced with $sth->{'TYPE'} (portable) or $sth->{'mysql_is_num'} (MySQL specific).
is_num

    Replaced with $sth->{'TYPE'} (portable) or $sth->{'mysql_is_num'} (MySQL specific).
IS_KEY

    Replaced with $sth->{'mysql_is_key'}.
is_key

    Replaced with $sth->{'mysql_is_key'}.
MAXLENGTH

    Replaced with $sth->{'mysql_max_length'}.
maxlength

    Replaced with $sth->{'mysql_max_length'}.
LENGTH

    Replaced with $sth->{'PRECISION'} (portable) or $sth->{'mysql_length'} (MySQL specific)
length

    Replaced with $sth->{'PRECISION'} (portable) or $sth->{'mysql_length'} (MySQL specific)
NUMFIELDS

    Replaced with $sth->{'NUM_OF_FIELDS'}.
numfields

    Replaced with $sth->{'NUM_OF_FIELDS'}.
NUMROWS

    Replaced with the result of $sth->execute() or $sth->{'mysql_affected_rows'}.
TABLE

    Replaced with $sth->{'mysql_table'}.
table

    Replaced with $sth->{'mysql_table'}.

AUTHORS

The current version of DBD::mysql is almost completely written by Jochen Wiedmann, and is now being maintained by Rudy Lippan ([email protected]). The first version's author was Alligator Descartes ([email protected]), who has been aided and abetted by Gary Shea, Andreas K�nig and Tim Bunce amongst others.

The Mysql module was originally written by Andreas K�nig <[email protected]>. The current version, mainly an emulation layer, is from Jochen Wiedmann.

COPYRIGHT

This module is Copyright © 2003 Rudolf Lippan; Large Portions Copyright © 1997-2003 Jochen Wiedmann, with code portions Copyright ©1994-1997 their original authors This module is released under the same license as Perl itself. See the Perl README for details.


Добавлено через 34 секунды
>perldoc DBI


--------------------
PM   Вверх
fantome
Дата 13.7.2007, 14:10 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 77
Регистрация: 5.2.2007

Репутация: 1
Всего: 1



allexeym
коннект к мускулу вызывается так 
Код

$dbh = DBI->connect ("dbi:mysql:database=$database_name;host=$host;port=$port", $user, $passwd, {RaiseError=>0, PrintError=>1, AutoCommit=>1} );

PM MAIL   Вверх
allexeym
Дата 13.7.2007, 14:20 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 12
Регистрация: 13.7.2007

Репутация: нет
Всего: нет



нифига не понял
кто иной?
какую доку использовать?
эту perldoc DBI?

или ту что ты привел?
PM MAIL   Вверх
nitr
Дата 13.7.2007, 14:25 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Участник Клуба
Сообщений: 2543
Регистрация: 10.2.2006
Где: Россия :)

Репутация: 37
Всего: 84



allexeym, и ту и другую ДОКУ smile То драйвер - описаны примеры и т.п.smile

Добавлено через 2 минуты и 5 секунд
а DBI это основа!!! Можно сказать самое важное ;)


--------------------
PM   Вверх
allexeym
Дата 13.7.2007, 14:32 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 12
Регистрация: 13.7.2007

Репутация: нет
Всего: нет



понято)

Код

$dbh = DBI->connect ("dbi:mysql:database=$database_name;host=$host;port=$port", $user, $passwd, {RaiseError=>0, PrintError=>1, AutoCommit=>1} );


а вот тут как указывать имя базы данных , хост, имя юзера, пароль?

нужно как-то указать переменные?

вот так?:

$database_name = myDB;
и т.п.
или как?

Добавлено через 9 минут и 22 секунды
понял 
надо так писать

$database_name = "myDB";

Это сообщение отредактировал(а) allexeym - 13.7.2007, 14:33
PM MAIL   Вверх
fantome
Дата 13.7.2007, 15:18 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 77
Регистрация: 5.2.2007

Репутация: 1
Всего: 1



allexeym, да, все переменные как строки должны быть инициализированы... ну и плюс чтоб небыло интерпретации символов с троке то желательно в одинарных кавычках...
то бинь вместо 
Код

$database_name = "myDB";

использовать
Код

$database_name = 'myDB';

так как пароль может содержать спецсимволы, то бишь иметь вид abcd\ntpcd\\
и при использовании двойных строка будет интерпретирована... то бишь, например, при выводе на экран будет 
Цитата

abcd
tpcd\


Это сообщение отредактировал(а) fantome - 13.7.2007, 15:24
PM MAIL   Вверх
allexeym
Дата 13.7.2007, 15:21 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 12
Регистрация: 13.7.2007

Репутация: нет
Всего: нет



_____________________________


добился того что выдаётся всего одна ошибка
Код


Can't locate object method "query" via package "DBI::db" at ./make_index.pl line 30.


вот эта линия


Код

$sth = $dbh->query("select Shop_ID,Shop_Name,Shop_SubDir,Div_ID,Aprove_Time from shop where Publish_St order by Aprove_Time desc");


что это значит?
PM MAIL   Вверх
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Perl"
korob2001
sharq
  • В этом разделе обсуждаются общие вопросы по языку Perl
  • Если ваш вопрос относится к системному программированию, задавайте его здесь
  • Если ваш вопрос относится к CGI программированию, задавайте его здесь
  • Интерпретатор Perl можно скачать здесь ActiveState, O'REILLY, The source for Perl
  • Справочное руководство "Установка perl-модулей", можно скачать здесь


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, korob2001, sharq.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Perl: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.1683 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.