L
Lars Eighner
Just another in a series of periodic requests asking if anyone has run
across a non-OO interface to MySQL.
across a non-OO interface to MySQL.
Just another in a series of periodic requests asking if anyone has run
across a non-OO interface to MySQL.
Lars said:Just another in a series of periodic requests asking if anyone has run
across a non-OO interface to MySQL.
Lars Eighner wrote:
I don't know of any off hand, but I'm assuming there could be something
out there, or you could write your own method.
However, I don't see a reason to seek such a thing out, just to avoid OO
(so I assume there's more to the question),
and that could be a pretty big wheel to
reinvent,
especially with all of the error checking, etc. Is there more to the
issue than that (being OO or not)?
Just another in a series of periodic requests asking if anyone has run
across
I'm sure you could program somethin like ADO.
But It sounds like your interested in biting your nuts off.
Just another in a series of periodic requests asking if anyone has run
across a non-OO interface to MySQL.
You could always create a security nightmare/spaghetti-nest by
invoking the mysql-tool from backticks..
`mysql -u root database -e "select * from table;"` or something to
that accord.
In our last episode,
Well, yes, that's how I will go if I have to build it myself. What I asking
is if the functions for parsing the return already exist somewhere.
As someone else posted, you could simply write your own function-style
wrappers around the DBI methods. Compared to basically rewriting DBI in
a functional style from scratch,
What exactly do you hope to gain by avoiding OO?
1) The horrible slowness and waste of resources.
2) Little ASCII art pictures of arrows in code (especially where the
arrows point the counterintuitive way)
LE> In our last episode, <[email protected]>, the
LE> lovely and talented Keith Keller broadcast on comp.lang.perl.misc:
LE> 1) The horrible slowness and waste of resources.
you don't know how fast it is until you compare it. premature
optimization and all. the DB itself is way slower than any OO perl code
you would use. this is a very silly (which means stupid) argument
defending your point.
also programmer time is way more expensive than cpu time. do you want to
waste all your hours developing this thing or just buy a faster cpu?
LE> 2) Little ASCII art pictures of arrows in code (especially where
LE> the arrows point the counterintuitive way)
just turn your head around and the arrows point in the right way. you
have a strange view of coding if that is what really bothers you. don't
go near c
or pl1 which had that arrow style for decades.
that makes less and less sense. what if mysql was written in c++ or uses
some c++? would you avoid it? you have an irrational fear like any other
phobia. it is all in your mind and not in the code.
1) The horrible slowness and waste of resources.
Oh my god. That's really the worst way to implement it.
Write simple wrapping functions around DBI, if you prefer to write
$rows = mysql_selectall_arrayref($dbh, "select * from table");
instead of
$rows = $dbh->selectall_arrayref("select * from table");
On Dec 21, 8:53 pm, "Peter J. Holzer" <[email protected]> wrote:
No need to write wrapper functions. A plain...
$rows = DBI::mysql_selectall_arrayref($dbh, "select * from
table");
...should work.
...
#!/usr/bin/perl
use warnings;
use strict;
use Benchmark 'cmpthese';
my $phandle = 23;
my $ohandle = MyClass->new();
my $arg = "this is an argument";
cmpthese(-3,
{
'proc' => sub { foo($phandle, $arg) },
'oo' => sub { $ohandle->foo($arg) },
});
sub foo {
my ($handle, $arg) = @_;
return $arg;
}
package MyClass;
sub new {
my ($class) = @_;
my $self = {};
return bless $self, $class;
}
sub foo {
my ($self, $arg) = @_;
return $arg;}
__END__
This little program compares a "procedural" subroutine call with an
oo-style method call.
Rate oo proc
oo 783445/s -- -7%
proc 838852/s 7% --
Hooray, procedural calls are 7 percent faster. That's a whopping 84
nanoseconds per call. But let's run it again:
Rate proc oo
proc 786957/s -- -7%
oo 842802/s 7% --
Oh, this time oo is 7 percent faster.
If you repeat that a few times you will see that in about 50 % of the
cases the procedural call is slightly faster than the oo call and in
50 % of the cases the oo call is slightly faster - or in other words,
the difference is not even measurable with a simple benchmark.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.