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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:27:51+00:00 2026-05-24T09:27:51+00:00

Situation/Problem I’m pulling all records form a table. I’m passing the returned data to

  • 0

Situation/Problem

I’m pulling all records form a table. I’m passing the returned data to my view. Num_rows says 5 but the result set is empty although there are records in the table.

controller

public function index()
{
     $this->load->model('Accessmodel', 'access');

     $data['query'] = $this->access->get_access_roles();

     $this->load->view('common/header');
     $this->load->view('admin/access/index', $data);
     $this->load->view('common/footer');
}

model

class Accessmodel extends Cruddy {
    function __construct() 
    {
        parent::__construct();
        self::$table = "EmployeeRoleAccess";
    }

    function get_access_roles()
    {
        return $this->db->get(self::$table);
    }
}

Relevant portion of cruddy

class Cruddy extends CI_Model {

protected static $table;

function __construct()
{

    parent::__construct();

}

function get_items()
{

    $this->db->from(self::$table);

    return $this->db->get();

}

view

<div class="column-left">
    <div class="sub-section-left">
        <?php include_once APPPATH . 'views/admin/menu.php'; ?>
    </div>
    <div class="sub-section-left shadows">
        <?php include_once APPPATH . 'libraries/minical.php'; ?>
    </div>
    </div>
    <div class="column-right">  
    <div class="sub-section-right">
        <h1>Employee Role Access Templates<input class="create right" type="button" name="" value="New Access Role" onClick=""></h1>
        <?php var_dump($query) ?>
    </div>
</div>

var_dump of query

object(CI_DB_mysql_result)#19 (8) {
  ["conn_id"]=>resource(11) of type (mysql link persistent)
  ["result_id"]=>resource(19) of type (mysql result)
  ["result_array"]=>array(0) { }
  ["result_object"]=>array(0) { }
  ["custom_result_object"]=>array(0) { }
  ["current_row"]=>int(0)
  ["num_rows"]=>int(5)
  ["row_data"]=>NULL
}
  • 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-24T09:27:52+00:00Added an answer on May 24, 2026 at 9:27 am

    I forgot that result is an object. I was trying to access it like an array

    echo $Result['Name'];
    

    which is why I used var_dump($Result) to see what was in the variable. When I saw result_array was empty I started to think it wasn’t returning data… this was NOT the case. I just had not returned data using result_array so OF COURSE IT WAS EMPTY! You can specify which way to return data with codeigniter, the default being through an object.

    Below is an example of the code I used in the view and it does work. I have to admit, I had not had any caffeine when I wrote this code this morning…. my apologies

    if($query->num_rows() > 0) { 
        foreach($query->result() as $Result) {
            echo $Result->Name . "<br />\n";
        }
    } else { 
        echo "There are no results!";
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our situation is as follows, but I'm curious about this problem in any situation.
I have the following... I wouldn't say problem, but situation. I have some HTML
This may be an odd situation but here is my current problem: I am
I know about this problem but here i am with something different situation. I
I don't really understand how yield statement works in this situation. The problem says
Situation: I want to track some Data with Google Analytics on the server-side. Problem:
Situation: need to find which layer the user has touched. Problem: Apple says we
I'm having a rather silly problem. I'll simplify the situation: I have a table
I have a problem that seems like its a result of a deadlock-situation. Whe
In my particular situation, I have a couple of solutions to my problem. I

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.