database abstraction layer with limit / total rowcount support

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rainer Collet

    database abstraction layer with limit / total rowcount support

    hi!

    i tested several php database abstraction layers (db, mdb(2), creole,
    adodb, etc), but i always missed one really important feature:
    i need a method for a limited select which gives me the resultset and
    the total number of rows the select would have returned without the
    limit.
    nativly this is very easy
    SELECT SQL_CALC_FOUND ROWS * FROM table LIMIT 0,10 in mysql for
    example.

    does anybody know an abstraction layer which supports this?

    thanks,
    rainer
  • Con

    #2
    Re: database abstraction layer with limit / total rowcount support

    Hi Rainer, you might want to try PEAR DB package.

    Good luck,

    -Conrad

    Comment

    • Manuel Lemos

      #3
      Re: database abstraction layer with limit / total rowcount support

      Hello,

      on 03/28/2005 11:22 AM Rainer Collet said the following:[color=blue]
      > i tested several php database abstraction layers (db, mdb(2), creole,
      > adodb, etc), but i always missed one really important feature:
      > i need a method for a limited select which gives me the resultset and
      > the total number of rows the select would have returned without the
      > limit.
      > nativly this is very easy
      > SELECT SQL_CALC_FOUND ROWS * FROM table LIMIT 0,10 in mysql for
      > example.
      >
      > does anybody know an abstraction layer which supports this?[/color]

      There seems to be not much point to add such feature to an abstraction
      layer when only MySQL supports it and you can implement what you
      portably using a simple SELECT count(*) FROM table without the limit clause.

      --

      Regards,
      Manuel Lemos

      PHP Classes - Free ready to use OOP components written in PHP
      Free PHP Classes and Objects 2026 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


      PHP Reviews - Reviews of PHP books and other products


      Metastorage - Data object relational mapping layer generator

      Comment

      • Kenneth Downs

        #4
        Re: database abstraction layer with limit / total rowcount support

        Rainer Collet wrote:
        [color=blue]
        > hi!
        >
        > i tested several php database abstraction layers (db, mdb(2), creole,
        > adodb, etc), but i always missed one really important feature:
        > i need a method for a limited select which gives me the resultset and
        > the total number of rows the select would have returned without the
        > limit.
        > nativly this is very easy
        > SELECT SQL_CALC_FOUND ROWS * FROM table LIMIT 0,10 in mysql for
        > example.
        >
        > does anybody know an abstraction layer which supports this?
        >
        > thanks,
        > rainer[/color]

        How hard would it be to hack this in yourself? If you are dealing with an
        abstraction layer, it must be constructing the SQL, and so it should be
        possible to take a form of the SQL w/o the LIMIT clause and then use
        db-specific *_num_rows() function.

        This does leave open the whole question of whether or not such things are
        good practice in terms of performance, but laying that aside it should be
        easy enough to add.

        --
        Kenneth Downs
        Secure Data Software, Inc.
        (Ken)nneth@(Sec )ure(Dat)a(.com )

        Comment

        Working...