Welcome Guest, Not a member yet? Register   Sign In
doctrine/codeigniter execute or fetcharray
#1

[eluser]Mutsop[/eluser]
Hi,

I'm confused on some issues with codeigniter and doctrine.

Im trying to get all values in an array and use a foreach to show each data.

Here you have my models: pastebin code [models]

And here is the query:
Code:
public function index() {
        
        $data['accounts'] = Doctrine_Query::create()
            ->select('u.username, a.api_id, c.characters_name')
            ->from('user u')
            ->leftJoin('u.api_keys a')
            ->leftJoin('a.characters c')
            ->execute();
        $data['message'] = $this->session->flashdata('message');
        $this->load->view('account_list', $data);
    }

and teh view:
Code:
<ul>
        &lt;?php foreach($accounts as $account):?&gt;
            <li>
                &lt;?php echo $account->api_id; ?&gt;
            </li>
        &lt;?php endforeach;?&gt;
        </ul>

When I use ->execute().. I get following error:
Quote:Fatal error: Uncaught exception 'Doctrine_Record_UnknownPropertyException' with message 'Unknown record property / related component "api_id" on "User"' in /public_html/AxialTilt/application/plugins/doctrine/lib/Doctrine/Record/Filter/Standard.php:55 Stack trace: #0 /public_html/AxialTilt/application/plugins/doctrine/lib/Doctrine/Record.php(1395): Doctrine_Record_Filter_Standard->filterGet(Object(User), 'api_id') #1 /public_html/AxialTilt/application/plugins/doctrine/lib/Doctrine/Record.php(1350): Doctrine_Record->_get('api_id', true) #2 /public_html/AxialTilt/application/plugins/doctrine/lib/Doctrine/Access.php(72): Doctrine_Record->get('api_id') #3 /public_html/AxialTilt/application/views/account_list.php(18): Doctrine_Access->__get('api_id') #4 /public_html/AxialTilt/syst in /public_html/AxialTilt/application/plugins/doctrine/lib/Doctrine/Record/Filter/Standard.php on line 55

When I use the ->fetchArray() I get
Quote:Trying to get property of non-object
//on the &lt;?php echo $account->api_id; ?&gt;

What to choose and how to solve the problem?
If I can get this right, I can use the same principle for all of my queries and data retrieval Big Grin


Kind regards
#2

[eluser]Mutsop[/eluser]
God its early in the morning Big Grin

Anyone able to help me on this? As I said, if I get the answer I would be able to use the same principles on other queries I need... Well on 90% of them Smile
#3

[eluser]Unknown[/eluser]
Hi,

Fatal error: Uncaught exception ‘Doctrine_Record_UnknownPropertyException’ with message ‘Unknown record property / related component “api_id” on “User

Doctrine_Query::create()
->select('u.username, a.api_id, c.characters_name')
->from('user u')
->leftJoin('u.api_keys a')
->leftJoin('a.characters c')
->execute();

I think you have to see in your model (api_keys) and verify that you have declared the primary key : 'api_id' and not 'id'

;-)




Theme © iAndrew 2016 - Forum software by © MyBB