$VAR2 = 'CREATE TABLE users (id INT, username VARCHAR(100)'; 这里少了个括号,呵呵。。。
2010-03-05 中华连珠网 五子棋百科 发件人: woosley. xu. 发送时间: 2010-03-05 10:45:15 收件人: [email protected] 抄送: 主题: Re: [PerlChina] 关于POE::Component::EasyDBI sql少了一个右括号 在 2010年3月5日 上午10:32,liu peng <[email protected]>写道: table_created是一个事件,不是指表是否存在。 在 2010年3月4日 下午8:01,Anthony WU <[email protected]>写道: table_created 是指你的表已��存在吧? -------- Original Message -------- Subject: [PerlChina] 关于POE::Component::EasyDBI From: liu peng <[email protected]> To: perlchina <[email protected]> Date: 4/3/2010 16:32 > 源码如下: > use strict; > use warnings; > > use Data::Dumper; > use Time::HiRes qw(time); > use POE; > use POE::Component::EasyDBI; > use POE::Component::Client::TCP; > use POE::Component::Client::SMTP; > use POE::Component::Net::FTP; > use POE::Filter::Line; > # Set up the DBI > POE::Component::EasyDBI->spawn( # or new(), witch returns an obj > alias => 'EasyDBI', > dsn => 'DBI:mysql:database=swatdb;host=127.0.0.1;port=3306', > username => 'root', > password => '', > ); > > # Create our own session to communicate with EasyDBI > POE::Session->create( > inline_states => { > _start => sub { > $_[KERNEL]->post( 'EasyDBI', > do => { > sql => "CREATE TABLE users (id INT, username > VARCHAR(100)", > event => "table_created", > } > ); > }, > > table_created => sub { > print "in table_created\n"; > my ($kernel, $session, %hash) = ($_[KERNEL], > $_[SESSION], %{$_[ARG0]}); > > print Dumper $session; > print "----------------------\n"; > print Dumper $_[ARG0]; > print "----------------------\n"; > print Dumper %hash; > > $_[KERNEL]->post( 'EasyDBI', > insert => { > # multiple inserts > insert => [ > { id => 1, username => 'foo' }, > { id => 2, username => 'bar' }, > { id => 3, username => 'baz' }, > ], > }, > ); > $_[KERNEL]->post( 'EasyDBI' => 'commit' ); > $_[KERNEL]->post( 'EasyDBI' => 'shutdown' ); > }, > } > ); > > POE::Kernel->run(); > > exit 0; > > > > 但运行之后报错: > C:\SWAT\tools\ServerDaemon>perl testmysql.pl > in table_created > $VAR1 = bless( [ > {}, > {}, > { > '_start' => sub { "DUMMY" }, > 'table_created' => sub { "DUMMY" } > } > ], 'POE::Session' ); > ---------------------- > $VAR1 = { > 'sql' => 'CREATE TABLE users (id INT, username VARCHAR(100)', > 'session' => 3, > 'error' => 'POE::Component::EasyDBI was shut down forcibly!', > 'action' => 'do', > 'id' => 0, > 'event' => 'table_created', > 'placeholders' => [] > }; > ---------------------- > $VAR1 = 'sql'; > $VAR2 = 'CREATE TABLE users (id INT, username VARCHAR(100)'; > $VAR3 = 'session'; > $VAR4 = 3; > $VAR5 = 'action'; > $VAR6 = 'do'; > $VAR7 = 'error'; > $VAR8 = 'POE::Component::EasyDBI was shut down forcibly!'; > $VAR9 = 'id'; > $VAR10 = 0; > $VAR11 = 'event'; > $VAR12 = 'table_created'; > $VAR13 = 'placeholders'; > $VAR14 = []; > > 用mysql的客户端可以连上数据库的 > 请大侠帮忙! > > -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 -- Woosley.Xu -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
