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


ru.cgi.perl

 
 - RU.CGI.PERL ------------------------------------------------------------------
 From : Comoderator of RU.CGI.PERL           2:5020/400     28 Feb 2001  17:57:33
 To : gk@ntvplus.com
 Subject : Moderatorial [+] (Re: MySQL troubles (HELP!!!))
 -------------------------------------------------------------------------------- 
 
 Здравствуй, George Krasotin.
 
 В твоём письме от Wed, 28 Feb 2001 12:04:37 +0000 (UTC) написано:
 
 gnc> Почему-то не находит запись. Таблицу создаю
 
 gnc>   my $sth =
 h->>prepare( 
 gnc>     'create table station (
 gnc>     id int not null auto_increment,
 gnc>     label varchar(255) not null') || die $dbh->errstr;
 
 $sth->>execute || die $dbh->errstr;
 
 $sth->>finish;
 
 gnc> Затем помещаю туда запись.
 
 gnc>     $sth = $dbh->prepare(
 gnc>     "insert into station( label) values( ?);") 
 gnc>      || die $dbh->errstr;
 
 $sth->>bind_param ( 1, 'Станция ?1');
 $sth->>execute || die $dbh->errstr;
 $sth->>finish;
 
 gnc> И затем пытаюсь искать там это все:
 
 gnc>   my $sth = $dbh->prepare('select * from station where label like ?;') 
 gnc> || die $dbh->errstr;
 $sth->>bind_param(1, 'Станция ?1');
 $sth->>execute || die $dbh->errstr;
 gnc>    $the_row  = $sth->fetchrow_hashref;
 gnc>    %the_hash = %$the_row; # тут ексепшен - типа undefined value
 gnc>     my $station_id = $the_hash{id} + 0;   
 $sth->>finish;
 
 gnc> Это селект не возвращает ничего... :(((
 
 gnc> Если делать так:
 
 gnc>   my $sth = $dbh->prepare('select * from station;') || die $dbh->errstr;
 $sth->>execute || die $dbh->errstr;
 gnc>   while ( my $my_row = $sth->fetchrow_hashref) {
 gnc>     my %my_hash = %$my_row;
 gnc>     my $label =  "$my_hash{label}";
 gnc>     print "$label \n";    
 gnc>     if ( $label eq 'Станция ?1') {
 gnc>       print "Found!"; # сюда никогда не приходит
 gnc>     }
 gnc>   }
 $sth->>finish;
 
 gnc> Хотя выводит на экран именно 'Станция ?1'
 
 gnc> Проблемы с языком, что ли?
 
 gnc> Regards,
 gnc> George.
 Оффтопик.
 -- 
 FIDO: Artem Chuprina, 2:5020/371.32, comoderator of RU.CGI.PERL
 Internet: Artem Chuprina <cmrcp@ran.pp.ru>, comoderator of fido7.ru.cgi.perl
 --- 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/16483c5b4182c.html, оценка 1 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional