WordPress.org

Forums

How to get information from a database (5 posts)

  1. hjeko
    Member
    Posted 2 years ago #

    Hello,

    I really like WordPress and I would like to use it on my next project.

    Here it is:

    - We want to have a site with first page a search
    - Second page is the list of results from the search
    - Third page is the page for a specific database entry that is hosted on a different mysql db (more than 500,000 entries)
    - Fourth page is an error page

    I am not sure how to set that up through wordpress. I am scared to put all db entries on the wordpress install. That's why it's in a different DB.

    Any thoughts on how to make that work and make it SEO friendly?

    Thanks!

    JMT

  2. jonradio
    Member
    Posted 2 years ago #

    To access a database other than the WordPress database, you simply grant your WordPress Database ID SELECT access to your other database. Then you code your query like this in PHP:

    global $wpdb;
    $wpdb->select('ebc');
    $memberlist = $wpdb->get_results('SELECT * FROM people WHERE member ORDER BY namelast');
    $wpdb->select(DB_NAME);

    That last line is essential or WordPress will fail almost immediately after.

  3. hjeko
    Member
    Posted 2 years ago #

    Hello jonradio,

    Thanks for your reply.

    Ok so after granting access to the other database, how do I set up search to this other database? What about getting access to results?

    and when I access an entry, how can I customize the entry?

    I am still new to this and I want to make sure this is simple and efficient.

    Thanks for your help!

    JMT

  4. jonradio
    Member
    Posted 2 years ago #

    Probably best to start reading here:
    http://codex.wordpress.org/Class_Reference/wpdb

  5. hjeko
    Member
    Posted 2 years ago #

    Thanks a lot :)

Topic Closed

This topic has been closed to new replies.

About this Topic