Still looking for a function-type MySQL interface

L

Lars Eighner

I'm still looking for a function-type database interface. CPAN returns more
than 1100 hits for mysql, but if there is a function interface, I haven't
found it.
 
M

Michael Vilain

Lars Eighner said:
I'm still looking for a function-type database interface. CPAN returns more
than 1100 hits for mysql, but if there is a function interface, I haven't
found it.

There are lots of CPAN entries for database stuff. What have you found?
 
L

Lars Eighner

In our last episode,
the lovely and talented Michael Vilain
broadcast on comp.lang.perl.misc:
There are lots of CPAN entries for database stuff. What have you found?

More than 1100 entries, but a many of the as I have inspected seem to
involve minus greater-than notation. As I said, I am looking for a
function-type database interface.
 
R

RedGrittyBrick

Lars said:
More than 1100 entries, but a many of the as I have inspected seem to
involve minus greater-than notation. As I said, I am looking for a
function-type database interface.

Ah, you want a *procedural* API rather than an *object-oriented* API.

AFAIK DBI is object oriented and most (all?) Perl DBMS interfaces use DBI.

What difficulties is the OO API causing you?
 
L

Lars Eighner

Ah, you want a *procedural* API rather than an *object-oriented* API.
AFAIK DBI is object oriented and most (all?) Perl DBMS interfaces use DBI.
What difficulties is the OO API causing you?

I can't read the notation as for example I can with the PHP mysql functions.

Sure, I can copy an example with minus greater-than notation from a tutorial
--- but in an hour, tomorrow, a week later, it's all greek to me. It isn't
remotely perlish, which would be something like:

opendb(MYDBHANDLE," gory details of db connection here");

and so forth.
 
R

RedGrittyBrick

I can't read the notation as for example I can with the PHP mysql
functions.

Interestingly, when I Googled this subject, I encountered a note saying
that the latest PHP API for MySQL is OO not procedural. I didn't read it
carefully, but I got the impression that if you upgrade MySQL you'd have
to switch to the OO API.

I'm afraid the world is moving from procedural to OO. I may be wrong but
I suspect module writers nowadays prefer to write OO APIs.

Sure, I can copy an example with minus greater-than notation from a
tutorial ---

I recommend you try to think of a->b as an *arrow* notation. The object
has a pointer to a subroutine, you use that pointer to call the
subroutine (sloppy terminology for simplicity).

but in an hour, tomorrow, a week later, it's all greek
to me.

I recommend you write yourself a few simple Perl OO toy programs. I
found it a good way to get familiar with Perl OO paradigms. There are
some good tutorials around and it only needs an hour or so if you have
any prior exposure to OO concepts.

perldoc perlboot; # http://perldoc.perl.org/perlboot.html
perldoc perltoot; # http://perldoc.perl.org/perltoot.html

It isn't remotely perlish,

It isn't Perl4ish but it is Perl5ish IMHO.

which would be something like:

opendb(MYDBHANDLE," gory details of db connection here");

and so forth.

Maybe you could write a procedural wrapper for the OO API. Fill the
wrapper with copious comments to yourself. You could centralise this
into a procedural module. I've no idea how feasible this is for you (or
anyone indeed), but it's an idea† you could consider.


Sorry not to be of more help.
 
U

Uri Guttman

LE> More than 1100 entries, but a many of the as I have inspected seem
LE> to involve minus greater-than notation. As I said, I am looking
LE> for a function-type database interface.

why do you care about this? it isn't called 'minus greater-than
notation' but OO. it is actually EASIER to use oo for this than
procedural. and DBI is the standard interface to dozens of db systems so
you can actually switch to another (if your sql is portable
enough). your request makes little sense for that reason.

and there is a module out there that will wrap an OO module into a
procedural one (it assumes a default object for it). you can easily use
it (i need to find it, i do think i know the author) or write your
own. just allocate a singleton object in a lexical and all your
procedural wrapper subs use it to make the OO calls. you save on passing
the object and the dreaded -> notation but you lose on everything else.

uri
 
D

Dr.Ruud

Lars said:
More than 1100 entries, but a many of the as I have inspected seem to
involve minus greater-than notation. As I said, I am looking for a
function-type database interface.

But why?

It is easy to abstract away yourself though.

Or see DBIx::perlish.
 
U

Uri Guttman

LE> I'm still looking for a function-type database interface. CPAN
LE> returns more than 1100 hits for mysql, but if there is a function
LE> interface, I haven't found it.

i still say learning OO perl is easy enough and you should learn
it. saying pointy ops are hard is a barbie excuse. but if you MUST have
a procedural API (functional is the wrong term), check out Sub::Exporter
on cpan. it can create a procedural API from an OO one and manage a
singleton object for you. you still need to do some work (if you can
handle it) to create your own api. this a fool's errand you are on
anyhow but i had to mention this module.

uri
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top