ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

DataMapper 1.6.0

September 05, 2008 12:32pm

Subscribe [115]
  • #421 / Jan 23, 2009 6:39pm

    OES

    127 posts

    So I would have an array of users and country in a list ie.

    Joe Bloggs - USA
    Joe Smith - United Kingdom

    Etc

  • #422 / Jan 23, 2009 6:42pm

    tdktank59

    322 posts

    try this

    $u = new User();
    $u->get();
    
    $u->country->get();
    
    foreach ($u->all as $user)
    {
        echo $user->name.' -> '.$user->country->name.'
    ';
    }
  • #423 / Jan 23, 2009 6:43pm

    OES

    127 posts

    Thats excatly the same as what I had ??

  • #424 / Jan 23, 2009 6:45pm

    tdktank59

    322 posts

    post your models for user and country

  • #425 / Jan 23, 2009 6:52pm

    OES

    127 posts

    Here are the models and controller.

    http://stikked.com/view/62619868

    Thank you

  • #426 / Jan 23, 2009 6:56pm

    tdktank59

    322 posts

    you dont have this part on the controller

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

    otherwise its not printing anything….

  • #427 / Jan 23, 2009 7:00pm

    OES

    127 posts

    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.

  • #428 / Jan 23, 2009 7:01pm

    tdktank59

    322 posts

    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?

  • #429 / Jan 23, 2009 7:43pm

    tdktank59

    322 posts

    Solution was to update the mysql driver….

  • #430 / Jan 23, 2009 9:28pm

    robertcsmith

    9 posts

    @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

    $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

    $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?

  • #431 / Jan 23, 2009 10:21pm

    robertcsmith

    9 posts

    hmmm…. also turning autotransactions back on and reordering DataMapper lines 604 - 615 to the following worked too:

    // Begin auto transaction
    $this->_auto_trans_begin();
    
    // Create new record
    $this->db->insert($this->table, $data);
                        
    // Sets the id property 
    // to the last insert's auto_increment value
    $this->id = $this->db->insert_id();
    
    // Complete auto transaction
    $this->_auto_trans_complete('save (insert)');
  • #432 / Jan 24, 2009 5:13pm

    Daniel H

    197 posts

    Has Datamapper ceased to exist….?

    http://stensi.com/datamapper/index.html

  • #433 / Jan 24, 2009 5:16pm

    tdktank59

    322 posts

    Not from what we know…

    The creator is really busy at the moment…

    you can download it from the wiki and the manual is in the download.
    If you have questions ask them here and people will try and help!

  • #434 / Jan 24, 2009 5:18pm

    Daniel H

    197 posts

    Okay cool - it’s fantastic contribution and was worried when I saw that.

  • #435 / Jan 24, 2009 5:50pm

    OverZealous

    1030 posts

    I recently talked to stensi.  He’s going through a server change, and it might be a little longer before he gets his website up.

    DataMapper is still alive and kicking, however, and some additions are in the works, AFAIK.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases