Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.1
#1

[eluser]WanWizard[/eluser]
DataMapper ORM 1.8.1

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.

To install DataMapper ORM, 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.1:
* New Features
o Alternative model locations are supported through the model_path advanced relationship parameter, or through the add_model_path static method.
o Added new truncate method to delete all records, and relations to those records.
o You can now pass a string as parameter to the to_array() and all_to_array() methods of the array extension, if you want to select only a single field.
o You can now run include_related on 'many' relations, see the docs for an explaination.
o Added new force_validation() method to force revalidation when you read a record from the database that would not pass the save rules.
o A new configuration value cascade_delete determines if delete operations need to cascade. See here.
o Added support for the new CI reactor versions, in which Lang and Loader library properties are no longer public.
o Added new where_between() methods to support "WHERE field BETWEEN a AND b" type queries.
o The json extension now supports related objects, which will be exported as nested objects ('id' fields only).
* Bug Fixes
o Added support for a database prefix when specifying a join table ('database.tablename').
o Extensions now receive the object that loads then as second parameter of the constructor, as documented.
o Do not unnecessarily join tables in a many to many relationship when defining a where clause on the related 'id' field.
o Fixed broken subqueries.
o Fixed broken like() queries: missing trailing space and no automatic escaping.
o Fixed nestedsets extension methods for moving sibling and child objects.
o Fixed language error messages in the log due to undefined validation labels when using CI Reactor or CI 2.0.2.
o Fixed incorrect SQL generated when using where() with a multi-value array just after a group_start().
o Fixed broken query caching when using group_start().
* Other Changes
o Datamapper now checks if the CodeIgniter database library is loaded when the Datamapper class is instantiated, and exits with an error message if not.
o The functionality of reciprocal self relationships is more clearly documented.

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.8.0, 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]ηυмвєяσηє[/eluser]
awesome, thanks for the update.
#3

[eluser]Basketcasesoftware[/eluser]
Oh. My aching head. More stuff to remember. %-P
#4

[eluser]WanWizard[/eluser]
Must be difficult for a basketcase... :lol:
#5

[eluser]Anestetikas[/eluser]
For example I have a database where I have films and tapes related many to many, with a join field called frame_count which contains how many frames does the film have in specific tape.

Now I want to select sums of it for a list of both films and tapes where it would list like:

Film title | frame_count <- for films list

and

Tape title | frame_count <- for tape list

Atm I use some thing like:

Code:
$tapes->select('(select sum(`frame_count`) from `films_tapes` where `films_tapes`.`tape_id` = `tapes`.`id`) as frame_count', FALSE);

I cant figure out any way of rewriting this in some subquery or other type of selection.
#6

[eluser]WanWizard[/eluser]
Easiest is to make a model for your relationship table. It doesn't have to define any relations.
Code:
$films_tape = new Films_tape();
$films_tape->select_func('SUM', '@frame_count', 'frame_count')->get();

If you want to access it via a relationship, you have to create a join using 'include_join_fields', which would add those fields to the select. You then have to come up with something clever to roll it all up into a single result, for example with a fake GROUP_BY.

Making join fields more accessable is definately something that needs to go onto the roadmap...
#7

[eluser]rherriman[/eluser]
I'm having some trouble with the latest update and I'm hoping you can shed some light on the situation. Here is a model-method I wrote that worked prior to the update:

Code:
/**
* Selects entries with an appropriate publishing date range.
* @return DataMapper Returns self for method chaining.
*/
public function published() {
    $now = date('Y-m-d H:i:s');
    return $this->where('publish_start_date <=', $now)
        ->group_start()
            ->where('publish_end_date IS NULL') // Published indefinitely OR...
            ->or_where('publish_end_date >=', $now) // Has not yet expired.
        ->group_end();
}

Following the update, wherever this method is called a fatal error is thrown: Call to a member function <whatever> on a non-object. According to var_dump, the method is now returning NULL rather than an updated DM object. What gives?

EDIT: for the record, I did wipe my production cache.

EDIT2: I suppose it's also useful to note the fields' datatype is datetime.
#8

[eluser]rherriman[/eluser]
On further inspection, it appears this is an issue with any and *all* group_end() statements.

I took a look at group_end in the DataMapper library, and discovered this:

Code:
/**
* Ends a query group.
* @return    DataMapper Returns self for method chaining.
*/
public function group_end()
{
    $value = str_repeat(' ', $this->_group_count) . ')';
    $this->db->ar_where[] = $value;
    if($this->db->ar_caching) $this->db->ar_cache_where[] = $value;

    $this->_where_group_started = FALSE;
}

As you can see, *nothing* is being returned by the method. I'm prepared to declare this a bug. Smile

EDIT: the changeset responsible
#9

[eluser]WanWizard[/eluser]
Sorry for the late response, I've been hidding in a corner feeling very ashamed... Sick

Bug (and two more introduced in the same set of changes) have been fixed. Code on bitbucket, and the downloads, have been updated.
#10

[eluser]rherriman[/eluser]
Just for clarification, you have now updated 1.8.1 with these fixes, correct?




Theme © iAndrew 2016 - Forum software by © MyBB