Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF, 078274121, info0a ip, should prodicers of software_based services be held liable or not liable for economic injuries

Links

XODOX
Impressum

#1: Apache::DBI

Posted on 2011-08-02 15:30:28 by Feng He

Hi,

I just want to develop a modperl application.
It's a handler, the database is Mysql.
Shall I use Apache::DBI, or DBI is just fine ?

Thank u.
Regards.

Report this message

#2: Re: Apache::DBI

Posted on 2011-08-02 16:34:04 by torsten.foertsch

On Tuesday, 02 August 2011 15:30:28 Feng He wrote:
> I just want to develop a modperl application.
> It's a handler, the database is Mysql.
> Shall I use Apache::DBI, or DBI is just fine ?

It depends. Apache::DBI provides a transparent connection cache. You can=20
forget the DB handle acquired at some time at the end of the request. The=20
next DBI::connect will then fetch the handle from the Apache::DBI cache.

On the other hand, all modern DBI versions have connect_cached() (only=20
ancient version lack this function) which provides much the same=20
functionality.

=46urther, applications that are implemented as modperl handlers often tend=
=20
to use a singleton to store the DBI handle. In this case Apache::DBI is=20
not necessary. However, in this scenario you'll have to take care of=20
cases when the connection is dropped unexpectedly. Nevertheless, I'd=20
prefer this strategy for new development because it gives you maximum=20
control over what is going on. But that's just my humble opinion.

Torsten F=F6rtsch

=2D-=20
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Report this message

#3: Re: Apache::DBI

Posted on 2011-08-02 18:49:04 by david

--Apple-Mail=_A609F58D-B2EF-4122-A8C9-A284602BEAC3
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii

On Aug 2, 2011, at 6:30 AM, Feng He wrote:

> I just want to develop a modperl application.
> It's a handler, the database is Mysql.
> Shall I use Apache::DBI, or DBI is just fine ?

I recommend DBIx::Connector.

Best,

David
--Apple-Mail=_A609F58D-B2EF-4122-A8C9-A284602BEAC3
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=us-ascii

<html><head></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
"><div><div>On Aug 2, 2011, at 6:30 AM, Feng He wrote:</div><br =
class=3D"Apple-interchange-newline"><blockquote type=3D"cite"><span =
class=3D"Apple-style-span" style=3D"border-collapse: separate; =
font-family: Helvetica; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: =
none; white-space: normal; widows: 2; word-spacing: 0px; =
-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span =
class=3D"Apple-style-span" style=3D"font-family: monospace; ">I just =
want to develop a modperl application.<br>It's a handler, the database =
is Mysql.<br>Shall I use Apache::DBI, or DBI is just fine =
?</span></span></blockquote></div><br><div>I recommend =
DBIx::Connector.</div><div><br></div><div>Best,</div><div><br></div><div>D=
avid</div></body></html>=

--Apple-Mail=_A609F58D-B2EF-4122-A8C9-A284602BEAC3--

Report this message

#4: Re: Apache::DBI

Posted on 2011-08-03 08:49:06 by Feng He

Hi,

Thank you all for the info.

I have finished writting the handler this morning, and have enabled
Apache::DBI in httpd.conf.
My handler is for this url:
http://bizstatus.game.yy.com/upload/

It accept client's uploaded data and write the data to database.
The strange stuff is, when I run more than one process for test, the
items number in database in not correct.

for example:

ab -n 100 -c 1 http://bizstatus.game.yy.com/upload/?arguments

This insert 100 items into database, the select result is correct.

But this one:

ab -n 100 -c 2 http://bizstatus.game.yy.com/upload/?arguments

or:

ab -n 100 -c 3 http://bizstatus.game.yy.com/upload/?arguments


When the client number is larger than one, the items number in
database is not correct.
it's always larger than 100, for example, 101, 102, 103 etc.

So, what's wrong with my program?

The handler looks as:

package ABC;
use strict;
use Apache2::RequestIO ();
use Apache2::RequestRec ();
use Apache2::Connection ();
use Apache2::RequestUtil ();
use Apache2::Request ();
use DBI;


use Apache2::Const -compile => qw(OK NOT_FOUND);

sub handler {

my $r = shift;
my $q = Apache2::Request->new($r);
my $ip = $r->connection->remote_ip;

my $v1 = $q->param('arg1');
my $v2 = $q->param('arg2');


my $db = 'mydb';
my $host = '127.0.0.1';
my $port = 3306;
my $user = '***';
my $passwd = '***';
my $dbh = DBI->connect("dbi:mysql:database=$db;host=$host;port=$port",
$user, $passwd)
or die $DBI::errstr;

my $str = "insert into mytable (v1,v2,check_time)
values(?,?,now())";

my $sth = $dbh->prepare($str);
$sth->execute($v1,$v2) or die $dbh->errstr;
$sth->finish;

$r->content_type('text/plain');
$r->print('OK');

return Apache2::Const::OK;
}

1;



Thank you!

Report this message

#5: Re: Apache::DBI

Posted on 2011-08-03 14:56:27 by Adam Prime

On 8/3/2011 2:49 AM, Feng He wrote:
> Hi,
>
> Thank you all for the info.
>
> I have finished writting the handler this morning, and have enabled
> Apache::DBI in httpd.conf.
> My handler is for this url:
> http://bizstatus.game.yy.com/upload/
>
> It accept client's uploaded data and write the data to database.
> The strange stuff is, when I run more than one process for test, the
> items number in database in not correct.
>
> for example:
>
> ab -n 100 -c 1 http://bizstatus.game.yy.com/upload/?arguments
>
> This insert 100 items into database, the select result is correct.
>
> But this one:
>
> ab -n 100 -c 2 http://bizstatus.game.yy.com/upload/?arguments
>
> or:
>
> ab -n 100 -c 3 http://bizstatus.game.yy.com/upload/?arguments
>
>
> When the client number is larger than one, the items number in
> database is not correct.
> it's always larger than 100, for example, 101, 102, 103 etc.
>
> So, what's wrong with my program?
>
> Thank you!

The first thing i'd suggest is looking at the access and error logs, and
seeing if there are anything in there that will tell you what's wrong
with it.

Nothing looks wrong at first glance to me, though you should check for
errors on the prepare call.

Adam

Report this message

#6: Re: Apache::DBI

Posted on 2011-08-03 15:47:16 by Perrin Harkins

On Wed, Aug 3, 2011 at 2:49 AM, Feng He <shorttag@gmail.com> wrote:
> ab -n 100 -c 3 http://bizstatus.game.yy.com/upload/?arguments
>
>
> When the client number is larger than one, the items number in
> database is not correct.
> it's always larger than 100, for example, 101, 102, 103 etc.
>
> So, what's wrong with my program?

I think your program is fine. I suspect ab is not that precise.

- Perrin

Report this message

#7: Re: Apache::DBI

Posted on 2011-08-03 19:47:23 by Jerry Pereira

--000e0cd328f4e7483b04a99d74ec
Content-Type: text/plain; charset=ISO-8859-1

How about DBIx::Connector?

On Tue, Aug 2, 2011 at 6:30 AM, Feng He <shorttag@gmail.com> wrote:

> Hi,
>
> I just want to develop a modperl application.
> It's a handler, the database is Mysql.
> Shall I use Apache::DBI, or DBI is just fine ?
>
> Thank u.
> Regards.
>



--
Your clothes may be the latest in style but you aint completely dressed
until you wear a smile!
Keep smiling : )

--000e0cd328f4e7483b04a99d74ec
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

How about DBIx::Connector?<br><br><div class=3D"gmail_quote">On Tue, Aug 2,=
2011 at 6:30 AM, Feng He <span dir=3D"ltr">&lt;<a href=3D"mailto:shorttag@=
gmail.com">shorttag@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex;">
Hi,<br>
<br>
I just want to develop a modperl application.<br>
It&#39;s a handler, the database is Mysql.<br>
Shall I use Apache::DBI, or DBI is just fine ?<br>
<br>
Thank u.<br>
Regards.<br>
</blockquote></div><br><br clear=3D"all"><br>-- <br>Your clothes may be the=
latest in style but you aint completely dressed until you wear a smile!<br=
>Keep smiling : )<br>

--000e0cd328f4e7483b04a99d74ec--

Report this message