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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:05:22+00:00 2026-06-01T16:05:22+00:00

After solving part of my problem over here , I realized that I could

  • 0

After solving part of my problem over here, I realized that I could get the data into the view, but then I had another problem.

(controller)

$this->load->model('testing/test_v_to_m_model');
$data['mydata'] = $this->test_v_to_m_model->display_character_info();
$this->load->view('testing/test_v_to_m_view', $data);

(model)

$query = $this->doctrine->em->createQuery("select u from ORM\Dynasties2\Characters u");
return $query->getResult();

(view)

foreach ($mydata as $key => $row) {
   print_r($row);
}

This returns output like so:

ORM\Dynasties2\Characters Object ( [id:ORM\Dynasties2\Characters:private] => 76 [name:ORM\Dynasties2\Characters:private] => Gwayn [whichFamily:ORM\Dynasties2\Characters:private] => 12 [bornDate:ORM\Dynasties2\Characters:private] => -467 [deathDate:ORM\Dynasties2\Characters:private] => -6 [marriedTo:ORM\Dynasties2\Characters:private] => 77 [marriedDate:ORM\Dynasties2\Characters:private] => -304 [marriageCode:ORM\Dynasties2\Characters:private] => [religion:ORM\Dynasties2\Characters:private] => 0 [isFemale:ORM\Dynasties2\Characters:private] => 0 [betrothedTo:ORM\Dynasties2\Characters:private] => [fathersId:ORM\Dynasties2\Characters:private] => 0 [successionOrder:ORM\Dynasties2\Characters:private] => 0 [isPregnant:ORM\Dynasties2\Characters:private] => [pregnantTurnsLeft:ORM\Dynasties2\Characters:private] => [marriedOutOfFamily:ORM\Dynasties2\Characters:private] => [bornMatrilineal:ORM\Dynasties2\Characters:private] => )

And so… I just don’t know how to do anything with this- I tried a nested foreach to echo data and couldn’t get it to work. I expect that its because this is an Object, not an Array, is that correct?

  1. How exactly can I access/manipulate these fields?

  2. Is there different code that I can use in my Doctrine2/CodeIgniter2 model that will give the data easier field names – like the equivalent to sql AS?

  • 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-01T16:05:23+00:00Added an answer on June 1, 2026 at 4:05 pm

    You should be able to access the object with pointers, like so:

    foreach ($mydata as $key => $row) {
       echo($row->id);
       echo($row->name);
    }
    

    stdClass is php’s generic empty class. Here is a nice tutorial on using this: http://krisjordan.com/dynamic-properties-in-php-with-stdclass

    Edit:

    Try using an accessor:

    echo($row->getId());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a program for class that involves solving the Chinese Postman problem
This question comes after solving my last question , I'd like to get some
I'm playing with Haskell and Project Euler's 23rd problem. After solving it with lists
After using F# option type for a while, I realize that it could be
After solving the other problem with routes , now I have another one. I
Edit: Below is my original question. After solving my problem, I thought I'd re-edit
The problem is that after a apache2 graceful the apc won't work correctly. There
Well, after solving this problem by naive STL set,I was reading the forum entries,there
After finally solving the jar signing problem (thank you everyone for your help!), a
i was solving the problem https://www.spoj.pl/problems/ACPC11A/ and here is my code : #include<iostream> #include<cstdio>

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.