• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DataMapper ORM v1.8.0

#1
[eluser]WanWizard[/eluser]
DataMapper ORM 1.8.0

Quote:Download the Latest Version Here

View the change log and the upgrade process
Having issues? Please look through the Troubleshooting Guide & FAQs
View the Complete Manual
Search the Manual
(Due to the server's caching configuration, you may need to forcibly refresh your browser to see the changes in the manual.)

DataMapper (DM) is an Object-Relational Mapper that builds on ActiveRecord. Data is loaded from database tables into objects, and relationships can be managed through simple, easy-to-read functions.

DataMapper ORM adds several important features to DM(Z), further enhancing it's usage, usually without requiring any code changes.

To install DataMapper ORM over DMZ, the (fairly simple) upgrade process is described here.

DataMapper offers these features:
• Everything is an object!
• Easy to setup, easy to use.
• Custom Validation on object properties.
• Lazy Loading (related objects are only loaded upon access).
• Relations and their integrity are automatically managed for you.
• One to One, One to Many, and Many to Many relations fully supported.
• Select data in the style of Active Record (with or without Method Chaining).

You can learn much more from the manual.

----------

Version 1.8.0:
* New Features
o Added a new extension which allows you to use Datamapper for nested set tree management.
o Added dutch language file.
o Added a new extension which allows you to use Datamapper for nested set tree management.
o It is now possible to define model relations, and update the model production cache, at runtime.
o Updated the select() method to accept an array of column names next to a comma delimited string, like CodeIgniters Activerecord does.
o The updated column can now be modified manually. The save method will save the update even if the updated timestamp is the only modified field.
o The column name is now used as key of the error->all array, which allows you to reference the column name when iterating over the errors.
o Added (experimental) support for reciprocal many-to-many relationships. See Advanced Relationships.
o Added the option to define the name of the relationship table in an advanced relationship definition.
o Added the option to run $object->{query}_related using a Datamapper object as $value. In case the object contains multiple values, the query will be transformed to a 'where_in' query using the id's in the objects resultset.
o >Added the option to run $object->{query}_related using an array of id's. If the array contains multiple values, the query will be transformed to a 'where_in' query using the id's in the objects resultset.
* Bug Fixes
o Fixed problem with get_iterated when using PHP 5.3+ which doesn't do an implicit type conversion from array to object, causing an isset() to fail.
o Fixed PHP fatal error when loading a model when using CI 2.0 packages or Modular CI, and a package or module is missing a models directory.
o Fixed incorrect SQL count and SQL error on get_paged and get_paged_iterated when paging through a related table, linked to the parent using a relationship table, and including a where clause on a parent column.
o Fixed race condition that could case a fatal error due to recursion when deleting ITFK's.
* Other Changes
o All language files have been converted to UTF-8.
o Replaced hardcoded check for the MY_ prefix with the 'subclass_prefix' config value when autoloading classes.
o When using include_join_fields, the id field of the relationship table is included as well.
o Added some info about the post_model_init method to the documentation.
o The manual now makes it clear that there are several reasons for a save to fail and gives some examples of what to check.

Make sure to check out the changelog — you won't want to skip this update!

----------

Bug reports and feature requests:

Please use the issue register / bug tracker on bitbucket to report new bugs or for new feature requests. If you do, please include in your description is link to the thread on this forum discussing the issue (if possible), so I have a link between the two and can keep track of all issues.

----------

Older Discussions: Version 1.7.1, Version 1.6.2, Version 1.5.4, Version 1.5.3 and older.

Thanks goes to Overzealous, for all he has achieved with DMZ. And to stensi, for providing such an amazing code base to work on.

#2
[eluser]dejavu[/eluser]
Excellent, thanks! The new nested sets library looks very promising for hierarchical data.

Thanks for your work on this, it wasn't trivial.

#3
[eluser]jparent[/eluser]
Thank you very much! New version is awesome!

#4
[eluser]momsenmeister[/eluser]
Hi,

I try using language lines for the validation, but I get the following error:
Quote:Parse error: syntax error, unexpected '(', expecting ')' in /var/www/virtual/beazy.org/htdocs/system/application/models/event.php on line 13

The language library and the helper are autoloaded and work fine everywhere else.

Anyone knows how to solve this?

Thx!

Code:
<?php

class Event extends DataMapper {
    
    var $has_many = array('user');

    var $validation = array(
        array(
            'field' => 'title',
            'label' => lang('wording_title'),
            'rules' => array('required'),
        ),
        array(
            'field' => 'date',
            'label' => lang('wording_date'),
            'rules' => array('required'),
        )
    );

    function Event()
    {
        parent::DataMapper();
    }
    
}

/* End of file event.php */
/* Location: ./application/models/event.php */

#5
[eluser]PoetaWD[/eluser]
Hey MAN !!!

GREAT NEWS !!! Thanks for keeping this project alive ! You really rock !!!

I will update my apps and see if everything runs smooth... Thank you SOOOO MUCCCHHHH!!!!!

#6
[eluser]WanWizard[/eluser]
@momsenmeister,

Are you sure? Afaik you can't use function calls ( lang() ) for assignment in a class property definition. You can do
Code:
<?php

class Event extends DataMapper {
    
    var $has_many = array('user');

    function Event()
    {
        parent::DataMapper();

        $this->validation = array(
                array(
                    'field' => 'title',
                    'label' => lang('wording_title'),
                    'rules' => array('required'),
                ),
                array(
                    'field' => 'date',
                    'label' => lang('wording_date'),
                    'rules' => array('required'),
                )
            );
    }
    
}

/* End of file event.php */
/* Location: ./application/models/event.php */

#7
[eluser]Unknown[/eluser]
Hi, First of all I really like data-mapper. It is very well thought. I was trying to follow the user guide , i was on get advanced when I came across this:
Code:
// Get a list of all male users
$u = new User();
$u->where('gender', 'M')->get();

// Get all the messages these males have posted
$p = new Post();
$u->where_related('user', 'id', $u->all)->get();
In the second pair of lines, there is a $post instance , but it is not used in the sentence , I tried but don't understand how to fix it. How would it be if it was fixed, of course there is an error here, but I can't make sense of what is the point of this example.

Please help.

#8
[eluser]madwhistler[/eluser]
Should be $p->where_related...
posts are being filtered by all related users from the prior selection.

#9
[eluser]madwhistler[/eluser]
WanWizard, thanks for the new update & your great work on carrying this on!

And of course, I have a question Wink

I'm using the HtmlForm extension to crank out new entry forms for a table, and it all works fine, including my related-field dropdowns.

But I'd like to pre-select a default choice on certain dropdowns for related fields, and I can't figure out a way to do this. i.e.
Code:
Class Color extends DataMapper { [objects with value "red", "green", "blue"]}

Class Block {
   var $validation = array(
    'color' => array(
        'rules' => array('is_natural'),
          'type'=>'dropdown'
    )...}
...
now I'd like to dynamically select 'green' as a default choice
...
then
$block->render_form($ff,'controller');

Since it's not a simple field, I can't just set $block->color = 'green', and if I do:

Code:
$color = new Color();
$color->where('name','green')->get();
$block->save($color);
$block->render_form($ff,'controller');

This works, but leaves me with a 'partial' database entry (since the user hasn't filled in the other $block fields). I don't really want to commit this object to the database yet, just set the initial default for the dropdown list (my 'real' dropdowns could be really long lists).

Any help or hints much appreciated...

#10
[eluser]WanWizard[/eluser]
[quote author="bachstein" date="1295131032"]In the second pair of lines, there is a $post instance , but it is not used in the sentence , I tried but don't understand how to fix it. How would it be if it was fixed, of course there is an error here, but I can't make sense of what is the point of this example.[/quote]
[strike]This looks like an error in the manual, I'll have a look.[/strike]
The error in the manual has been corrected.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
3 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.