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

Discussion in 'Perl Misc' started by Ole, Dec 16, 2004.

  1. Ole

    Ole Guest

    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!
     
    Ole, Dec 16, 2004
    #1
    1. Advertising

  2. (Ole) wrote in news:41c19cf7.866000
    @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
     
    A. Sinan Unur, Dec 16, 2004
    #2
    1. Advertising

  3. Ole wrote:

    > 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
     
    Gregory Toomey, Dec 16, 2004
    #3
  4. (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?

    --
    (Andrew A. Raines)
     
    Andrew A. Raines, Dec 16, 2004
    #4
  5. Ole

    Guest

    (Ole) wrote:
    > 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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Dec 16, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dhananjay
    Replies:
    1
    Views:
    1,150
    sloan
    Dec 18, 2006
  2. Luke Wu

    Abstraction layer between C and CPU

    Luke Wu, Jan 21, 2005, in forum: C Programming
    Replies:
    30
    Views:
    845
    Chris Torek
    Feb 5, 2005
  3. Kobu
    Replies:
    18
    Views:
    616
    Keith Thompson
    Jul 23, 2006
  4. BJ Dierkes

    Database Abstraction Layer And/Or ORM

    BJ Dierkes, Sep 24, 2007, in forum: Python
    Replies:
    1
    Views:
    320
    Bruno Desthuilliers
    Sep 24, 2007
  5. jis
    Replies:
    11
    Views:
    353
    Tobias Müller
    Jan 30, 2013
Loading...

Share This Page