Part of the EllisLab Network
   
50 of 53
50
DataMapper ORM v1.8.0
Posted: 23 December 2011 09:59 AM   [ Ignore ]   [ # 491 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4108
Joined  11-04-2008

It’s one of the reasons why I’m busy redesigning DM for v2.0.

The current code is 3 years old, largely PHP4 based (it it still compatible with CI 1.7), and limited when it comes to more complicated queries.

 Signature 

WanWizard.eu | Modular CI, an HMVC solution | DataMapper ORM

Profile
 
 
Posted: 23 December 2011 10:00 AM   [ Ignore ]   [ # 492 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  370
Joined  06-12-2009

That is great news. smile Much appreciated. I am loving how easy it is to work with objects now.

 Signature 

- Simon

Profile
 
 
Posted: 27 December 2011 12:50 PM   [ Ignore ]   [ # 493 ]  
Summer Student
Total Posts:  2
Joined  10-08-2010

Hi,

I can’t get automated time-stamps to work. I’ve set unix_timestamp and local_time to true in the config, and my fields in the table are both int(10) unsigned, but when I check the last query I can see it inserts 0 in the field.

INSERT INTO `users` (`group_id`, `username`, `email`, `password`, `created_on`, `active`,
 `
ip_address`) VALUES (2'username''user@email.com''123456'01'127.0.0.1'

I’ve loaded the ci date helper just in case.

Have I missed a setting or a setup-thing?

Profile
 
 
Posted: 27 December 2011 07:24 PM   [ Ignore ]   [ # 494 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4108
Joined  11-04-2008

Have you configured DataMapper to use ‘created_on’ as the ‘created_field’, either in the global config file or in your model?

And what do you mean by ‘fields’? I see only one date field in this query.

 Signature 

WanWizard.eu | Modular CI, an HMVC solution | DataMapper ORM

Profile
 
 
Posted: 28 December 2011 01:52 AM   [ Ignore ]   [ # 495 ]  
Summer Student
Total Posts:  1
Joined  12-28-2011

Is there any update for the last version used?

swimming fin

Profile
 
 
Posted: 06 February 2012 06:33 AM   [ Ignore ]   [ # 496 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  370
Joined  06-12-2009

@Lars Steen: I am pretty sure that a unix_timestamp is not a int field in mysql. There is a ‘timestamp’ type, maybe try that?

Now I also have a question relating to automated timestamps. I got it working, it is very nice. I defined the names for my created_field and updated_field in the config.

The question: Is DataMapper supposed to not write the created and updated fields on the join tables? I would like to know when a certain person got assigned a book for example. DM doesn’t seem to update my join table between user and book.

 Signature 

- Simon

Profile
 
 
Posted: 06 February 2012 06:44 AM   [ Ignore ]   [ # 497 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4108
Joined  11-04-2008

It is perfectly fine to store a unix timestamp in an INT(11), or an INT(10) UNSIGNED. I do it all the time.

Automatically adding timestamps is a model feature. As join tables don’t have models, that feature is not available. This will be addressed in 2.0, which will use models for join tables too…

 Signature 

WanWizard.eu | Modular CI, an HMVC solution | DataMapper ORM

Profile
 
 
Posted: 06 February 2012 07:10 AM   [ Ignore ]   [ # 498 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  370
Joined  06-12-2009

Then I don’t know for the timestamp smile

I seem to be hitting things that will be introduced in 2.0. Thanks for the quick response!

 Signature 

- Simon

Profile
 
 
Posted: 14 February 2012 04:31 PM   [ Ignore ]   [ # 499 ]  
Summer Student
Total Posts:  9
Joined  10-19-2010

Hi guys, I’m struggling to set up the validation rules to validate the related items on a specific object, ie: A user can have no more than 3 products related to it.

I believe DataMapper can check for this validation using _related_max_size rule in Related validation, but I can’t figure out how to use it on the $validation array in the model.

So far I’ve tried this in both my user and product models:

var $validation = array(
    
'product' => array(
         
'rules' => array('max_size' => 3)
    )
); 

Can somebody show me an example on how to set up this at the model, controller and finally the view (specificly how to show the errors for this)?

Edit: What I mean is, a user has many products, and can create a certain amount of them, let’s say 3 products, when that amount is reached, the user can no longer create products, and this validation rule should not permit the user to create more products.

This would be the DB Schema:

Users table
------------------
id   |  username  |
------------------ 
Products table
------------------------
id  user_id |  name   |
------------------------ 

Thanks!

Profile
 
 
Posted: 14 February 2012 06:07 PM   [ Ignore ]   [ # 500 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4108
Joined  11-04-2008

That should work without problem, providing there is an entry in the $has_one or $has_many arrays in the User model called ‘products’ (and you should define it in User, because that’s where you want the relation to be checked).

 Signature 

WanWizard.eu | Modular CI, an HMVC solution | DataMapper ORM

Profile
 
 
   
50 of 53
50