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]
  • #541 / Feb 17, 2009 12:19am

    xtramix

    7 posts

    Or, heck, forget the correct conventions, and just call it Specie 😊

    That’s what fixed it for me.

    Thanks a lot.

  • #542 / Feb 17, 2009 4:04am

    Matthew Lanham

    145 posts

    @OverZealous.com

    Clearly you are spending / or have spent a lot of time on the project, i’m glad it is still being maintained as there should be an ORM built into Codeigniter…

    If you need anything tested etc then i’d be happy to help, we have a couple of fairy complex projects that are utilizing Datamapper.

  • #543 / Feb 17, 2009 4:23am

    OverZealous

    1030 posts

    @Matthew Lanham

    Well, the testing version of DataMapper I posted earlier really needs a looking over.  I don’t, obviously, use every feature of DataMapper myself.  I also

    There is a ton of code changes (some 150 changes, including major new sections).  I’ve been using it on my project, but my project is still being built. 😊

    If you don’t mind flipping back, I have a pretty good explanation of the changes back there.

    Probably the biggest problem - even for me - is that using the new, more advanced features requires some complex code.  I don’t personally like the scheme, but I haven’t had a lot of time to refine it lately.

    @Everyone
    While I’m at it, I’ll post the version I’m currently using.  It doesn’t have many changes - mostly a tiny bugfix, and some very minor tweaks suggested by stensi a few days ago.

    There is one potentially important change.  Through my testing, I determined that I was more likely to make changes to ‘join_self_as’, while keeping a default ‘other_field’, so I swapped the defaults.  I doubt that too many are using this functionality, yet.

  • #544 / Feb 17, 2009 2:38pm

    GregX999

    39 posts

    Well, I got my user model error messages almost 100% working (thanks to hints from OverZealous). But the one issue I’m still having is with using the “matches” validation function.


    Here’s my rule:

    array(
      ‘field’ => ‘confirm_password’,
      ‘label’ => ‘Password Confirmation’,
      ‘rules’ => array(‘matches’ => ‘password’)
    ),

    I modified the _matches function in datamapper.php and added a line so I could see if it was being called:

    function _matches($field, $other_field)
    {
    echo "X";exit;
    return ($this->{$field} !== $this->{$other_field}) ? FALSE : TRUE;
    }


    And no matter how I fill in the rest of the fields (and wether the confirmation matches the password) - that “X” is never echoed - so the function isn’t ever being called.

    Greg

  • #545 / Feb 17, 2009 2:42pm

    tdktank59

    322 posts

    @Matthew Lanham

    Well, the testing version of DataMapper I posted earlier really needs a looking over.  I don’t, obviously, use every feature of DataMapper myself.  I also

    There is a ton of code changes (some 150 changes, including major new sections).  I’ve been using it on my project, but my project is still being built. 😊

    If you don’t mind flipping back, I have a pretty good explanation of the changes back there.

    Probably the biggest problem - even for me - is that using the new, more advanced features requires some complex code.  I don’t personally like the scheme, but I haven’t had a lot of time to refine it lately.

    @Everyone
    While I’m at it, I’ll post the version I’m currently using.  It doesn’t have many changes - mostly a tiny bugfix, and some very minor tweaks suggested by stensi a few days ago.

    There is one potentially important change.  Through my testing, I determined that I was more likely to make changes to ‘join_self_as’, while keeping a default ‘other_field’, so I swapped the defaults.  I doubt that too many are using this functionality, yet.

    So far working with original functionality.

    I will be trying the local relations and ill let you know how that goes!

  • #546 / Feb 17, 2009 3:36pm

    tdktank59

    322 posts

    OverZealous.com

    Can you post up some examples of the actual models and everything.

    It would make testing this sooo much easier. The text file is a bit hard to follow.

    Im having an issue with relations on the table such as:
    (the red lines are the related user fields)

    CREATE TABLE IF NOT EXISTS `dqips` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `version` int(10) unsigned NOT NULL,
      `title` varchar(255) NOT NULL,
      `description` text NOT NULL,
      `demographics` text NOT NULL,
      `impact_to_organization` text NOT NULL,
      `automation_options` text NOT NULL,
      `resolution_approach` text NOT NULL,
      `re_extraction_schedule` text NOT NULL,
      `conversion_impact` text NOT NULL,
      `presented_date` int(10) unsigned NOT NULL,
      `created_on` int(10) unsigned NOT NULL,
      `estimated_completion_date` int(10) unsigned NOT NULL,
      `estimated_count_auto` int(10) unsigned NOT NULL,
      `estimated_count_manual` int(10) unsigned NOT NULL,
      `estimated_count_not_valid` int(10) unsigned NOT NULL,
      `author_id` int(10) unsigned NOT NULL,
      `dciu_staff_1_id` int(10) unsigned NOT NULL,
      `dciu_staff_2_id` int(10) unsigned NOT NULL,

      PRIMARY KEY (`id`),
      UNIQUE KEY `title` (`title`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

    Heres my user $has_many

    var $has_many = array(  "brainstorm",
                                "role",
                                "team",
    
                                /* DQIP User Fields */
                                "dqip_author"       => array (  'class' => 'user',
                                                                'other_field' => 'author'),
                                "dqip_dciu_staff_1" => array (  'class' => 'user',
                                                                'other_field' => 'dciu_staff_1'),
                                "dqip_dciu_staff_2" => array (  'class' => 'user',
                                                                'other_field' => 'dciu_staff_2')
                             );

    and the dqip $has_one

    var $has_one = array( "author"          => array(   'class' => 'user',
                                                            'other_field' => 'dqip_author' ),
    
                              "dciu_staff_1"    => array(   'class' => 'user',
                                                            'other_field' => 'dqip_dciu_staff_1'),
    
                              "dciu_staff_2"    => array(   'class' => 'user',
                                                            'other_field' => 'dqip_dciu_staff_2')
                              );
  • #547 / Feb 17, 2009 3:53pm

    OverZealous

    1030 posts

    @GregX999

    ignore what I wrote here if you saw it earlier.

    @tdtank59
    I’ll try to come up with some better examples today.  I apologize for the cryptic nature of the file.  It’s not easy building examples when you are thinking in code!

    In your example, I think the problem is that has_one fields must allow NULLs.  It’s my fault, because I didn’t specify this, and it is counter-intuitive at first.  The reason for this is that the object gets saved before the relationships, so those fields are NULL at first.  Also, they will get set to NULL when deleting or replacing the relationship, just due to the nature of DataMapper.

    Otherwise, your code looks pretty good!  Hopefully it will work for you.

  • #548 / Feb 17, 2009 4:11pm

    OverZealous

    1030 posts

    @GrecX999
    I’ve been trying to figure out what would cause this.  I use the matches function, and my code looks an awful lot like yours (except, you aren’t hashing your passwords).

    Are you sure that ‘confirm’ is getting set?  It’s possible you are setting a field with a different name than the validation rules.  You should debug/output both the password and the confirm field.  You could also echo the name and value of every field that is being looked at within validate().  I’ve done that a few times while debugging.

    Is it possible that you’ve somehow overridden _matches() in your User class?

    (I’m still wondering if there is a bug that _matches isn’t called when nothing is typed into the confirmation field - I’ll look into that when I get a chance.  You could try adding ‘required’ to the confirm field, if you want, to see if that fixes your problem.)

  • #549 / Feb 17, 2009 4:46pm

    tdktank59

    322 posts

    Still not working

    Heres my saving statements
    note: each variable is initialized and has a value

    $d = New Dqip();
            $d->version                     = $version;
            $d->title                       = $title;
            $d->description                 = $description;
            $d->demographics                = $demographics;
            $d->impact_to_organization      = $impact_to_organization;
            $d->automation_options          = $automation_options;
            $d->resolution_approach         = $resolution_approach;
            $d->re_extraction_schedule      = $re_extraction_schedule;
            $d->conversion_impact           = $conversion_impact;
            $d->presented_date              = $presented_date;
            $d->estimated_completion_date   = $estimated_completion_date;
            $d->estimated_count_manual      = $estimated_count_manual;
            $d->estimated_count_auto        = $estimated_count_auto;
            $d->estimated_count_not_valid   = $estimated_count_not_valid;
    
            $d->save();
            echo $d->error->string;
    
            $d = New Dqip();
            $d->where('id',1)->get();
    
            $ds = New Data_source();
            $ds->where('id',2)->get();
    
            $d->save(array($ds,'author'=>$author,
                            'dciu_staff_1'=>$dciu_staff_1,
                            'dciu_staff_2'=>$dciu_staff_2 ));
            echo $d->error->string;

    Heres my dm config as well

    $config['prefix']                   = '';
    $config['join_prefix']              = 'join_';
    $config['error_prefix']             = '';
    $config['error_suffix']             = '
    ';
    $config['created_field']            = 'created_on';
    $config['updated_field']            = 'updated_on';
    $config['local_time']               = TRUE;
    $config['unix_timestamp']           = TRUE;
    $config['auto_transaction']         = TRUE;
    $config['auto_populate_has_many']   = TRUE;
    $config['auto_populate_has_one']    = TRUE;
  • #550 / Feb 17, 2009 5:31pm

    OverZealous

    1030 posts

    What error are you getting?  Or, if not an error, what is happening?

  • #551 / Feb 17, 2009 5:38pm

    tdktank59

    322 posts

    Nothing…

    It creates the entry, setups the data_source relation (with join_table) and dosn’t do anything else…

    I modified the values in the dqips insert. They are all valid inputs in the original version. So don’t worry about that issue.

    0.0004     SELECT * FROM `dqips` LIMIT 1

    0.0003     SELECT *
    FROM (`dqips`)
    WHERE `title` = ‘Titlie’
    LIMIT 1

    0.0006     INSERT INTO `dqips` (`version`, `title`, `description`, `demographics`, `impact_to_organization`, `automation_options`, `resolution_approach`, `re_extraction_schedule`, `conversion_impact`, `presented_date`, `created_on`, `estimated_completion_date`, `estimated_count_auto`, `estimated_count_manual`, `estimated_count_not_valid`) VALUES (‘version’, ‘title’, ‘description’, ‘demographics’, ‘impact_to_organization’, ‘automation_options’, ‘resolution_approach’, ‘re_extraction_schedule’, ‘conversion_impact’, ‘presented_date’, ‘created_on’, ‘estimated_completion_date’, ‘estimated_count_auto’, ‘estimated_count_manual’, ‘estimated_count_not_valid’)

    0.0006     SELECT *
    FROM (`dqips`)
    WHERE `id` = 1

    0.0001     SELECT * FROM `data_sources` LIMIT 1

    0.0001     SELECT *
    FROM (`data_sources`)
    WHERE `id` = 2

    0.0003     SELECT *
    FROM (`join_data_sources_dqips`)
    WHERE `dqip_id` = ‘1’
    AND `data_source_id` = ‘2’

  • #552 / Feb 17, 2009 5:53pm

    OverZealous

    1030 posts

    I know this is ugly, but is it possible to add this to datamapper.php line 2529 (after $related_properties is set), and send me the output?

    update: stupid brain - meant $related_properties

    echo("$related_field => {$object->model}");
    var_dump($related_properties);

    I’m trying to track down where this could be causing an issue, and I think it might somehow be related to the saving an array of data (I haven’t used that much), but it’s hard to tell where the code is stopping.

    Update:
    I’ve recreated your code, at least somewhat, and cannot find any place where it fails 😖 .

    However, I did come across one somewhat cool item.  If you are saving multiple related objects that all have the same related field, you have to specify the save like this:

    $object->save( array(
        'user' => array(
            $user1,
            $user2
        );
    ));
    // alternately
    $object->save( array($user1, $user2), 'user'); // this only works when saving just users.

    This is because you can (obviously) only have one item per key in an array, so you have to specify the the items as an array.  What I like is that actually reflects the actual relationship pretty well.

  • #553 / Feb 17, 2009 6:14pm

    tdktank59

    322 posts

    data_source => data_sourcearray(4) { ["class"]=> string(11) "data_source" ["join_self_as"]=> string(4) "dqip" ["other_field"]=> string(4) "dqip" ["join_other_as"]=> string(11) "data_source" }

    thats it thats new

  • #554 / Feb 17, 2009 6:38pm

    OverZealous

    1030 posts

    Note: the above issue has been resolved, it is not a DataMapper bug.

  • #555 / Feb 17, 2009 6:39pm

    tdktank59

    322 posts

    Note: the above issue has been resolved, it is not a DataMapper bug.

    It was my bug… Had to setup the users as objects not values…

    (totally spaced on this)

    Thanks for the help

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

ExpressionEngine News!

#eecms, #events, #releases