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 - 02-16-2009

[eluser]xtramix[/eluser]
[quote author="OverZealous.com" date="1234865523"]Or, heck, forget the correct conventions, and just call it Specie :-)[/quote]

That's what fixed it for me.

Thanks a lot.


DataMapper 1.6.0 - El Forum - 02-17-2009

[eluser]Matthew Lanham[/eluser]
@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.


DataMapper 1.6.0 - El Forum - 02-17-2009

[eluser]OverZealous[/eluser]
@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.


DataMapper 1.6.0 - El Forum - 02-17-2009

[eluser]GregX999[/eluser]
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


DataMapper 1.6.0 - El Forum - 02-17-2009

[eluser]tdktank59[/eluser]
[quote author="OverZealous.com" date="1234880600"]@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.[/quote]

So far working with original functionality.

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


DataMapper 1.6.0 - El Forum - 02-17-2009

[eluser]tdktank59[/eluser]
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)

Quote: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
Code:
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
Code:
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')
                          );



DataMapper 1.6.0 - El Forum - 02-17-2009

[eluser]OverZealous[/eluser]
@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.


DataMapper 1.6.0 - El Forum - 02-17-2009

[eluser]OverZealous[/eluser]
@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.)


DataMapper 1.6.0 - El Forum - 02-17-2009

[eluser]tdktank59[/eluser]
Still not working

Heres my saving statements
note: each variable is initialized and has a value
Code:
$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
Code:
$config['prefix']                   = '';
$config['join_prefix']              = 'join_';
$config['error_prefix']             = '';
$config['error_suffix']             = '<br />';
$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;



DataMapper 1.6.0 - El Forum - 02-17-2009

[eluser]OverZealous[/eluser]
What error are you getting? Or, if not an error, what is happening?