CodeIgniter Forums
DataMapper 1.6.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: DataMapper 1.6.0 (/showthread.php?tid=11358)



DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]OES[/eluser]
So I would have an array of users and country in a list ie.

Joe Bloggs - USA
Joe Smith - United Kingdom

Etc


DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]tdktank59[/eluser]
try this

Code:
$u = new User();
$u->get();

$u->country->get();

foreach ($u->all as $user)
{
    echo $user->name.' -> '.$user->country->name.'<br />';
}



DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]OES[/eluser]
Thats excatly the same as what I had ??


DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]tdktank59[/eluser]
post your models for user and country


DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]OES[/eluser]
Here are the models and controller.

http://stikked.com/view/62619868

Thank you


DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]tdktank59[/eluser]
you dont have this part on the controller

Code:
foreach ($u->all as $user)
{
    echo $user->name.' -> '.$user->country->name.'<br />';
}

otherwise its not printing anything....


DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]OES[/eluser]
Like I have said I get the sQL error as per my first post. So no point outputting anything when I got errors :-).

I know normal get works just for users with no errors and I have done foreach no problem with that data.


DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]tdktank59[/eluser]
just to make sure you did update your mysql driver? if no check out the troubleshooting in the manual.

BTW do you have an instant messenger so we stop spamming the board?


DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]tdktank59[/eluser]
Solution was to update the mysql driver....


DataMapper 1.6.0 - El Forum - 01-23-2009

[eluser]robertcsmith[/eluser]
@tdtank
Without diving into it too much something is amuck with autotransactions as turning it off in the datamapper config using similar models worked perfectly

controller
Code:
$b = new Brainstorm();
$b->short_desc = "test1";
$b->long_desc = "a long description";
$b->priority = 1;
$b->est_count_total = 77;
$b->status = 1;
$b->origin_date = now();
    

$it = new Issue_type();
$it->where('id', 2)->get();

$b->save($it);

var_dump($b);

A Debug shows that DataMapper line 614
Code:
$this->id = $this->db->insert_id();
which uses the new mysql_driver.php insert_id method on line 310
returns an id of 0

but with the config set to false it properly returns the id of the newly created record

so yeah... something is amuck in the driver i think?