EllisLab text mark
Advanced Search
23 of 67
23
   
DataMapper ORM v1.8.2
Posted: 15 April 2012 06:21 AM   [ # 331 ]   [ Rating: 0 ]
Avatar
Joined: 2009-11-10
26 posts

https://bitbucket.org/wanwizard/datamapper/src/a58c1b0c9927

 
Posted: 15 April 2012 08:32 AM   [ # 332 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4489 posts
Ruben. - 15 April 2012 04:51 AM

The documentation is down.

Is there a way to download the documentation for offline usage? Thanks.

Has been fixed, forgot to check all services after server upgrades last night…

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM <= LOOKING FOR A NEW MAINTAINER!

 
Posted: 15 April 2012 10:38 AM   [ # 333 ]   [ Rating: 0 ]
Joined: 2012-04-15
2 posts
WanWizard - 15 April 2012 08:32 AM
Ruben. - 15 April 2012 04:51 AM

The documentation is down.

Is there a way to download the documentation for offline usage? Thanks.

Has been fixed, forgot to check all services after server upgrades last night…

Thanks smile

 
Posted: 17 April 2012 09:16 AM   [ # 334 ]   [ Rating: 0 ]
Joined: 2010-12-27
11 posts

Hi.
I am using datamapper.
I have one issue.
I have table in db ‘events’ each event have start_date/end_date/time fields, at first i should render events where(‘start_date <=’ now()) and where(‘end_date >=’ now)with order_by(‘time’) and then i should render future events where(‘star_date >’ now()) with order_by(‘start_date, time’), all this events i should get in one reguest.
Please give me some advice, how can i do this reguest.

Paul.

 
Posted: 17 April 2012 10:55 AM   [ # 335 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4489 posts

Simplest answer: two different queries.

You can also do a single query, include the start_date in the order, and deal with the split in your code.

You can also do something complex like “SELECT CASE WHEN start_date <= now() AND end_date >= now() THEN 0 ELSE 1 as futurevent ORDER BY futurevevent ASC, time ASC”. You can then use $object->futureevent in your code…

(assuming you’re using MySQL)

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM <= LOOKING FOR A NEW MAINTAINER!

 
Posted: 18 April 2012 10:31 AM   [ # 336 ]   [ Rating: 0 ]
Joined: 2010-10-27
114 posts

Iv noticed that changing the validation error delimiter doesn’t seem to be working, it just keep using the p tags. Am I doing something wrong?

class User extends DataMapper {
   
    
// Insert related models that user can have just one of.
 
var $has_one = array('user_type''user_profile');

 
// Insert related models that user can have more than one of.
 
var $has_many = array('order');
    
    var 
$error_prefix '<span class="input-notification error png_bg">';
    var 
$error_suffix '</span>';
 
    
    public 
$updated_field 'field_does_not_exist';
    
    
// Optionally, don't include a constructor if you don't need one.
    
function __construct($id NULL)
    
{
        parent
::__construct($id);
    
 
Posted: 18 April 2012 12:15 PM   [ # 337 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4489 posts

This has been asked a few times recently.

You’re not using the latest version (v1.8.2.1), please download the latest version (https://bitbucket.org/wanwizard/datamapper/get/tip.zip) from Bitbucket to solve this problem (this is not only true for error delimiters, but for every config value you want to override in the model.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM <= LOOKING FOR A NEW MAINTAINER!

 
Posted: 18 April 2012 03:41 PM   [ # 338 ]   [ Rating: 0 ]
Joined: 2010-12-21
25 posts

Greetings! I’ve been racking my brain about this for a couple days, and finding it hard to accomplish what I want using Advanced Relationships techniques.

I have a contentprovider model, and a retentionrule model. Contentprovider will have two retention rules; a CDN one, and a Local one.

contentprovider

var $has_one = array(
            
'priority' => array(), 
            
'cdn_rule' => array(
                
'class' => 'retentionrule',
                
'other_field' => 'cdn_retentionrule'
            
), 
            
'local_rule' => array(
                
'class' => 'retentionrule',
                
'other_field' => 'local_retentionrule'
            
)
        ); 

retentionrule

var $has_one = array(
            
'cdn_retentionrule' => array(
                
'class' => 'contentprovider',
                
'other_field' => 'cdn_rule'
            
),

            
'local_retentionrule' => array(
                
'class' => 'contentprovider',
                
'other_field' => 'local_rule'
            
),
            
        ); 

For the tables, they have ‘id’ fields and the join tables look like this:

contentprovider_retentionrule
id, cdn_retentionrule_id, local_retentionrule_id, contentprovider_id

..And I’m getting

An Error Was Encountered

Unable to relate contentprovider with retentionrule.

I just know I’m doing something wrong, but I can’t figure what it is!? I’m on CI2 & DM1.8

 
Posted: 18 April 2012 07:48 PM   [ # 339 ]   [ Rating: 0 ]
Joined: 2012-04-13
1 posts

thank you

 
Posted: 19 April 2012 11:14 AM   [ # 340 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4489 posts

@diZzyCoDeR,

Since you haven’t defined the ‘join_self_as’ and ‘join_other_as’ fields of the relation, Datamapper will try to determine them automatically.

For ‘join_self_as’, it will use the “other_field” value. So your relationship table should contain:
- cdn_retentionrule_id (check)
- local_retentionrule_id (check)

For ‘join_other_as’, it will use the relation name. So your relationship table should also contain:
- cdn_rule_id (missing)
- local_rule_id (missing)

For the retentionrule model, it should be the other way around.

As this is clearly not what you want, define the ‘join_self_as’ and ‘join_other_as’ values for your relations, so they point to the correct keys in your relationship table.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM <= LOOKING FOR A NEW MAINTAINER!

 
Posted: 19 April 2012 12:21 PM   [ # 341 ]   [ Rating: 0 ]
Joined: 2010-12-21
25 posts

Thanks Wiz, cheers. So, if I’m reading your phonebook, I’ve got the following now:

contentprovider

var $has_one = array(
            
'priority' => array(), 
            
'cdn_rule' => array(
                
'class' => 'retentionrule',
                
'other_field' => 'cdn_retentionrule',
                
'join_self_as' => 'contentprovider',
                
'join_other_as' => 'cdn_retentionrule',
            ), 
            
'local_rule' => array(
                
'class' => 'retentionrule',
                
'other_field' => 'local_retentionrule',
                
'join_self_as' => 'contentprovider',
                
'join_other_as' => 'local_retentionrule',
            )
        ); 

retentionrule

var $has_one = array(
            
'cdn_retentionrule' => array(
                
'class' => 'contentprovider',
                
'other_field' => 'cdn_rule',
                
'join_self_as' => 'cdn_retentionrule',
                
'join_other_as' => 'contentprovider',
            ),

            
'local_retentionrule' => array(
                
'class' => 'contentprovider',
                
'other_field' => 'local_rule',
                
'join_self_as' => 'local_retentionrule',
                
'join_other_as' => 'contentprovider',
            ),
            
        ); 

Yet, I still get the same error… (?)

 
Posted: 19 April 2012 03:29 PM   [ # 342 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4489 posts

On which statement exactly do you get the error?

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM <= LOOKING FOR A NEW MAINTAINER!

 
Posted: 19 April 2012 04:16 PM   [ # 343 ]   [ Rating: 0 ]
Joined: 2010-12-21
25 posts
$relations some_func_to_get_relationships_in_an_array();
$success $contentprovider->save($relations); 

where $relations is set like this previously (ie, in function)

$related_model = new $related_model_name();
$related_model->where_in('id'$val)->get();
$return_array[] $related_model->all

so my models look right then? maybe I should whip up a simpler test…

 
Posted: 19 April 2012 04:20 PM   [ # 344 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4489 posts

You’re not being clear.

What is $relations EXACTLY? An object? An array of objects? Which object(s)? Something else?

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM <= LOOKING FOR A NEW MAINTAINER!

 
Posted: 19 April 2012 04:44 PM   [ # 345 ]   [ Rating: 0 ]
Joined: 2010-12-21
25 posts

Sorry, mate. It’s really complicated, I’m trying to abstract; let me break it down.

$relations ends up being an array of objects, come ca:

Array
(
    
[0] => Array
        (
            
[0] => Priority Object
                
(
                    
[has_one] => Array
                        (
                        )

                    
[has_many] => Array
                        (
                            
[show] => Array
                                (
                                    
[class] => show
                                    [other_field] 
=> priority
                                    [join_self_as] 
=> priority
                                    [join_other_as] 
=> show
                                    [join_table] 
=> 
                                    
[reciprocal] => 
                                    
[auto_populate] => 
                                    
[cascade_delete] => 1
                                
)

                            
[contentprovider] => Array
                                (
                                    
[class] => contentprovider
                                    [other_field] 
=> priority
                                    [join_self_as] 
=> priority
                                    [join_other_as] 
=> contentprovider
                                    [join_table] 
=> 
                                    
[reciprocal] => 
                                    
[auto_populate] => 
                                    
[cascade_delete] => 1
                                
)

                        )

                    
[validation] => Array
                        ( 

...

it’s actually a dynamic CrUD I built to handle basic editing of tables in the DB, and it works famously, until this scenario. All my other relationships are simple 1:1 or n:n (and combinations thereof).  So when I added this advanced relationship setup it changed the game a bit.

But the test I’m doing is simply a form-submission to the controller which finds the relationships for the model being saved, and then passes those relationships to the ->save() function (as seen above).

 
23 of 67
23