Автор Тема: DBI в mod_perl  (Прочитано 2273 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн salw

  • Заглянувший
  • Новичок
  • *
  • Сообщений: 1
  • +0/-0
  • 0
    • Просмотр профиля
    • http://cgiscripts.r2.ru
DBI в mod_perl
« : 25 Января 2002, 11:06:41 »
Столкнулся с проблемой. В скрипте под Apache::Registry не работает DBI, при
этом cgi работет на ура.


При этом в логе появляются строки -

Had to create DBD::mysql::dr::imp_data_size unexpectedly at /path/to/DBI/DBI.pm line 687
Had to create DBD::mysql::db::imp_data_size unexpectedly at /path/to/DBI/DBI.pm line 687
Undefined subroutine &DBD::mysql::db::_login called at mysql.pm line 31

Оффлайн Green Kakadu

  • Координатор
  • Глобальный модератор
  • Ветеран
  • *****
  • Сообщений: 2757
  • +1/-0
  • 0
    • Просмотр профиля
    • http://gnezdo.webscript.ru
заграница нам поможет
« Ответ #1 : 25 Января 2002, 13:45:06 »
http://thingy.kcilink.com/modperlguide/databases/Apache_DBI_does_not_work.html
http://perl.apache.org/guide/performance.html#mod_perl_Database_Performance_Im (давольно долго грузится т.к. много)

Возможно поможет:

# Apache::Registry script
  -------------------------
  use strict;
  use vars qw($dbh);
 
  $dbh ||= SomeDbPackage->connect(...);

Стоит обратить внимание, что $dbh - глобальная переменная

И еще, оттудова же:

Apache::DBI allows you to make a persistent database connection. With this module enabled, every connect() request to the plain DBI module will be forwarded to the Apache::DBI module. This looks to see whether a database handle from a previous connect() request has already been opened, and if this handle is still valid using the ping method. If these two conditions are fulfilled it just returns the database handle. If there is no appropriate database handle or if the ping method fails, a new connection is established and the handle is stored for later re-use. There is no need to delete the disconnect() statements from your code. They will not do anything, the Apache::DBI module overloads the disconnect() method with a NOP. When a child exits there is no explicit disconnect, the child dies and so does the database connection. You may leave the use DBI; statement inside the scripts as well.

The usage is simple -- add to httpd.conf:

     PerlModule Apache::DBI
 


It is important to load this module before any other DBI, DBD::* and ApacheDBI* modules!

     db.pl
  ------------
  use DBI ();
  use strict;
 
  my $dbh = DBI->connect( \'DBI:mysql:database\', \'user\', \'password\',
                          { autocommit => 0 }
                        ) || die $DBI::errstr;
 
  ...rest of the program
 в исканиях.

Оффлайн Green Kakadu

  • Координатор
  • Глобальный модератор
  • Ветеран
  • *****
  • Сообщений: 2757
  • +1/-0
  • 0
    • Просмотр профиля
    • http://gnezdo.webscript.ru
вот еще
« Ответ #2 : 25 Января 2002, 13:47:50 »
http://thingy.kcilink.com/cgi-bin/modperlguide.cgi?q=DBI
решение где то тут.
::DBI - м-да, иногда смайлики вставляются не там где нужно
 в исканиях.

 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28