WordPress.org

Support

Support » Plugins and Hacks » Record paging with $wpdb

Record paging with $wpdb

  • Dystopia777
    Member

    @dystopia777

    Hi,

    I’ve been trying to get my head around the $wpdb object and having looked briefly at the manual I couldn’t see there being any automagical way of paging records.

    Am I right to think that the wpdb object is just for query abstraction and implementing paging routines is something you have to do for yourself?

    Any help appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Paging routines? Could you be a bit more specific about what you’re talking about?

    If you mean the pages as in page 2 shows the next 10 posts, then that’s implemented, but in the WP_Query object, not in the WP_DB object. The query controls the actual querying of posts and such.

    Dystopia777
    Member

    @dystopia777

    Sure, sorry. I’m having a go at writing a simple plugin that lists rows from a table I have created myself. I wanted to know if there was a built in way of paging result sets, just like you suggested – 10 per page or whatever.

    I’ll have a look at the docs for wp_query.

    Any advice appreciated!

    If this is for a table you made yourself, then wp_query won’t help you.

    The way WordPress does paging is by using the MySQL LIMIT parameter. So to get the first page of 10, it does LIMIT 0,10. To get the second page, it does LIMIT 10,10.

    Basically, it’s LIMIT offset,row-count.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Record paging with $wpdb’ is closed to new replies.