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 7727295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:25:29+00:00 2026-06-01T05:25:29+00:00

So basically I have a helper – function records() { $ci = get_instance(); $ci->db->order_by(date,

  • 0

So basically I have a helper –

function records()
{        
  $ci = get_instance();                     
  $ci->db->order_by("date", "desc");
  $ci->db->limit(20);
  $query = $ci->db->get('records');
  $data =array();
  foreach($query->result_array() as $orders)
  {
     $data[] = $orders;
  }            
  return $data;
}   

I need to pass data from it to view, but currently I’m only passing data from table records. In additional, after I get $data[] from records, I need to check the current record id, and then pass in the same $data[] all user details from another table which is users instead. How can I do it? So basically I muts first get all data from records, check from what user the record is, and then search that user with get_where(‘users’, array(‘id’ => $data[‘user_id’])); and add user data to either new array or the same $data[] array. Is this something doable? If yes, please show me example of it.

  • 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-06-01T05:25:30+00:00Added an answer on June 1, 2026 at 5:25 am

    I think you want to do a join?

      $ci->db->order_by("date", "desc");
      $ci->db->limit(20);
      $query = $ci->db->from('records')->join('users', 'records.user_id=users.id')->get();
    

    http://codeigniter.com/user_guide/database/active_record.html

    Make sure you modify the query to use the correct field name in the records table that references the user’s id. The above comments are right though – helpers are absolutely not the place for queries. Really, I can’t think of any good example of using get_instance to grab the CI object in a helper, they should probably be CI independent functions.

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

Sidebar

Related Questions

I have a helper function, which basically calls CompareTo on two objects, but does
I have a TextArea html helper method I'm calling in a foreach loop. Basically,
I have written a browser helper object to get the text between the tags
Basically I have a set of checkboxes that are dynamically created from view data
I have a static class in my solution that is basically use a helper/ultility
I have this Linq to SQL query sequence that is basically returning a search
This is contrived, but its basically what I'm doing. I have an a @helper
I have a table with records that has delete links. Basically I followed the
I basically have three tables, posts, images and postimages (this simply contains the ids
I basically have a unix process running and it is doing some heavy processing

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.