Главная страница


ru.cgi.perl

 
 - RU.CGI.PERL ------------------------------------------------------------------
 From : George Krasotin                      2:5020/400     28 Feb 2001  16:04:37
 To : All
 Subject : MySQL troubles (HELP!!!)
 -------------------------------------------------------------------------------- 
 
 Почему-то не находит запись. Таблицу создаю
 
   my $sth =
 
 h->prepare( 
 
     'create table station (
     id int not null auto_increment,
     label varchar(255) not null') || die $dbh->errstr;
 
   $sth->execute || die $dbh->errstr;
           
   $sth->finish;
 
 Затем помещаю туда запись.
 
     $sth = $dbh->prepare(
     "insert into station( label) values( ?);") 
      || die $dbh->errstr;
 
     $sth->bind_param ( 1, 'Станция ?1');
     $sth->execute || die $dbh->errstr;
     $sth->finish;
 
 И затем пытаюсь искать там это все:
 
   my $sth = $dbh->prepare('select * from station where label like ?;') 
 || die $dbh->errstr;
   $sth->bind_param(1, 'Станция ?1');
   $sth->execute || die $dbh->errstr;
    $the_row  = $sth->fetchrow_hashref;
    %the_hash = %$the_row; # тут ексепшен - типа undefined value
     my $station_id = $the_hash{id} + 0;   
   $sth->finish;
 
 Это селект не возвращает ничего... :(((
 
 Если делать так:
 
   my $sth = $dbh->prepare('select * from station;') || die $dbh->errstr;
    $sth->execute || die $dbh->errstr;
   while ( my $my_row = $sth->fetchrow_hashref) {
     my %my_hash = %$my_row;
     my $label =  "$my_hash{label}";
     print "$label \n";    
     if ( $label eq 'Станция ?1') {
       print "Found!"; # сюда никогда не приходит
     }
   }
   $sth->finish;
 
 Хотя выводит на экран именно 'Станция ?1'
 
 Проблемы с языком, что ли?
 
 Regards,
 George.
 --- ifmail v.2.15dev5
  * Origin: NTV Internet (2:5020/400)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 MySQL troubles (HELP!!!)   George Krasotin   28 Feb 2001 16:04:37 
 Moderatorial [+] (Re: MySQL troubles (HELP!!!))   Comoderator of RU.CGI.PERL   28 Feb 2001 17:57:33 
Архивное /ru.cgi.perl/15512a3d8fc18.html, оценка 1 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional