Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 958919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:56:30+00:00 2026-05-16T00:56:30+00:00

I am building a web application and have opted to use similar table and

  • 0

I am building a web application and have opted to use similar table and field names to WordPress in my application. By that I mean I have a users table and a usermeta table similar to how WordPress works.

Forgive me for making this question so big, I opted to be as descriptive as possible in this question.

The usermeta table has the following table values;

umeta_id
user_id
meta_key
meta_val

As an example I have the following data in my usermeta table;

user_id = 1
meta_key = first_name
meta_value = ‘dwayne

user_id = 1
meta_key = last_name
meta_value = charrington

In my users table I have the following example data;

ID = 1
user_login = admin
user_pass = ui3h423h4o82374
user_email = test@test.com

Basically what I want to do is using the following join which seems to kind of work, sort of:

$db = $this->db;
$db->select('wolf_users.ID, wolf_usermeta.user_id AS ID', FALSE);
$db->select('wolf_users.user_login AS user_login', FALSE);
$db->select('wolf_users.user_email AS user_email', FALSE);
$db->select('wolf_users.user_status AS status', FALSE);
$db->select('wolf_usermeta.meta_key AS meta_key', FALSE);
$db->select('wolf_usermeta.meta_value AS meta_value', FALSE);
$db->from('wolf_users');
$db->join('wolf_usermeta', 'wolf_users.ID = wolf_usermeta.user_id', 'left');
$db->where('wolf_usermeta.user_id = wolf_users.ID');
$q = $db->get();
return $q->result_array();

Firstly: result_array seems to be returning duplicate data from my database (which is a bit strange) have I formatted my join incorrectly or is there something I am missing to prevent this? returning results just using $q->result() seems to stop duplicate data being returned.

I am using Dwoo for my templating and when I echo out the variable that is holding the data using print_r it shows no duplicate query content when using query, but shows duplicate content when using result_array (almost like it looped over the usermeta table a few times).

One of the pages I am using this database query on is a page that lists all clients in a database and then fetches matching data from the usermeta table. So my question is how do I access data from both tables and then display it in my application using a foreach in my view template?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:56:30+00:00Added an answer on May 16, 2026 at 12:56 am

    You understand how joins work right?

    By joining meta data to a user, the user will be repeated for each meta data entry you pull out.

    This could be avoided with a foreach after pulling data out of the database or by splitting your query into two queries.

    $user = $this->db
        ->select('ID, user_login, user_email, user_status AS status')
        ->where('ID', $id)
        ->get('wolf_users')
        ->row_array();
    
    if(!$user)
    {
        return FALSE;
    }
    
    $user['meta'] = $this->db
        ->select('meta_key, meta_value')
        ->where('user_id', $id)
        ->get('wolf_usermeta')
        ->result_array();
    
    return $user;
    

    A few general MySQL points and tips:

    wolf_users.ID, wolf_usermeta.user_id AS ID
    

    No need, you only need to select the user ID once. The second select will override the first, which is of course the same.

    $db->select('wolf_usermeta.meta_value AS meta_value', FALSE);
    

    You don’t need to do that, the table name will be removed from the result, so renaming them is pointless.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an web application that I want users to have specific permissions to
I am building a web application that makes use of Entity Framework. I have
I am building a web application and have been told that using object oriented
We have a PeopleSoft installation and I am building a separate web application that
I am building a web application that will need to allow users to save
I am building a web application on Google App Engine that requires users to
I am building a web application that have several requirements for the client: 1.
I am building a web application that has two names/domains pointing to it. I
So I'm building a web application and I have an ajax request that pings
We're building a web application that is available to both authenticated and anonymous users.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.