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

  • Home
  • SEARCH
  • 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 8595309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:24:15+00:00 2026-06-12T00:24:15+00:00

I have the following query, which returns a single row. MODEL: function get_guide_first(){ $this->db

  • 0

I have the following query, which returns a single row.

MODEL:

function get_guide_first(){
        $this->db
            ->select('*')
            ->from('guides_entries')
            ->order_by("guide_name", "asc")
            ->limit(1, 0)
            ->join('guides_content', 'guides_content.guide_id = guides_entries.guide_id'); 
        $query = $this->db->get();
        return $query->result_array();
    }

Here is my controller:

CONTROLLER:

public function get_first_guide(){
        $page_data['guide']=$this->guides_model->get_guide_first();
        $this->load->view('guidepage', $page_data);
    }

I then run a foreach() loop in my view (or controller sometimes).

VIEW:

foreach($guide as $row){
    echo $row['guide_content'];
    $activecat=$row['guide_slug'];
 }

Now what I would ideally like to do is return an array back from my model but even using:

return $query->row();

returns an object rather than an array.

1)How can I return this row as a 2d array?
e.g. so that I could echo a result in the controller as guide[‘col_name’] rather than guide()->col_name.

2)how would I pass the object to my view so that I could use $guide->col_name from there (I would need to pass this along eith the $page_data array)

  • 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-12T00:24:16+00:00Added an answer on June 12, 2026 at 12:24 am

    If i’m reading your question right: You can use row_array instead of result_array

    I think:
    return $query->result_array();

    returns an

    array(
       0 => array(
          'blah' => 'blah',
          'smile' => 'smile'
       )
    
    );
    

    to return just an associated array.

    row array will return

    array(
      'blah' => 'blah',
      'smile' => 'smile'    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query which have 1000 rows select staffdiscountstartdate,datediff(day,groupstartdate,staffdiscountstartdate), EmployeeID from tblEmployees
I have the following query which returns a list of questions and the possible
I have the following MQL query which successfully returns the record for William Shakespeare.
I have the following query which works: SELECT ?page ?lat ?long (bif:st_distance(?geo, bif:st_point(42.883, -72.8981)))
I have a simple query over a table, which returns results like the following:
The following query returns a single row, as desired. The 'contracts' table has 6
I have query which returns single value (i.e) count. I'm exceuting it using the
I have the following query: SELECT script FROM d_stages WHERE id IN (SELECT g.stage
I have following query which take more than a minute to execute, how can
I have the following query which is working fine, but I also want to

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.