Is there a field-data abstraction layer for DBI/MySQL?

O

Ole

Hi there!

I'm currently looking for a kind of "field-data abstraction layer for
DBI/MySQL". It should solve the issues of table layout and data
access.
Now I try to find out if there is a module availalble of if I need to
breed my own.

some pseudo code to illustrate what I mean:

at the moment I need to do this

- do some SQL query
- @row = handle->fetchrow_array
- access data-field by $data-in-field = $row[4]

here I need to know what the table layout is.
And I can't hardly change the table layout after I introduced a
specific layout into my code

I should be like this:
access sql and fetch data-field in one step:
-$data-in-field = $table-$row{id}-$field{name}

this should solve all my problems, as I don't really care about table
layout and efficiently accessing sql, everything should be done in the
background.
This should make it possible to build tree like data structures into a
sql table

Is there such a solution?
Thanks!
 
A

A. Sinan Unur

(e-mail address removed) (Ole) wrote in @news.rz.uni-duesseldorf.de:
Hi there!

I'm currently looking for a kind of "field-data abstraction layer for
DBI/MySQL". It should solve the issues of table layout and data
access.
....

This should make it possible to build tree like data structures into a
sql table

I am not sure what you are really asking for, but do you think Class::DBI
might help?

http://search.cpan.org/~tmtm/Class-DBI-0.96/

Sinan
 
G

Gregory Toomey

Ole said:
Hi there!

I'm currently looking for a kind of "field-data abstraction layer for
DBI/MySQL". It should solve the issues of table layout and data
access.
Now I try to find out if there is a module availalble of if I need to
breed my own.

some pseudo code to illustrate what I mean:

at the moment I need to do this

- do some SQL query
- @row = handle->fetchrow_array
- access data-field by $data-in-field = $row[4]

here I need to know what the table layout is.
And I can't hardly change the table layout after I introduced a
specific layout into my code

I should be like this:
access sql and fetch data-field in one step:
-$data-in-field = $table-$row{id}-$field{name}

this should solve all my problems, as I don't really care about table
layout and efficiently accessing sql, everything should be done in the
background.
This should make it possible to build tree like data structures into a
sql table

Is there such a solution?
Thanks!

You are VERY confused. Read a good database book (Date or Ullman).

Your select statement will give you the row names, bases on tables/joins.
You can use aliases to assist Perl with name bindings
eg select max(x) * min(y) as myresult from table
You can then use myresult as a field.


mysql does not support hierarchical queries directly. Oracle does support
this with "connect by" and "start" keywords.

There is a workaround for mysql - storing the 'path' to a node & using it as
a sort key. I've used it here - http://www.pchq.com.au/cat_all.htm

gtoomey
 
A

Andrew A. Raines

(e-mail address removed) (Ole) writes:

[...]
I should be like this:
access sql and fetch data-field in one step:
-$data-in-field = $table-$row{id}-$field{name}

Will not DBI::fetchall_hashref() do what you want?
 
X

xhoster

Hi there!

I'm currently looking for a kind of "field-data abstraction layer for
DBI/MySQL". It should solve the issues of table layout and data
access.
Now I try to find out if there is a module availalble of if I need to
breed my own.

some pseudo code to illustrate what I mean:

at the moment I need to do this

- do some SQL query
- @row = handle->fetchrow_array
- access data-field by $data-in-field = $row[4]

here I need to know what the table layout is.

Of course you don't need to know the table layout. You only need to know
what the layout of your SQL statement is, which is just two lines up.
Unless, of course, your SQL was "select * from....".
So don't do that.
And I can't hardly change the table layout after I introduced a
specific layout into my code
Nonsense.


I should be like this:
access sql and fetch data-field in one step:
-$data-in-field = $table-$row{id}-$field{name}

What is with all the minus signs? This a Perl group, so
make your psuedocode at least somewhat Perlish.

Xho
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top