Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord inspired ORM
#11

[eluser]nmweb[/eluser]
I think the performance is reasonable. You could perhaps look at return standard mysql object or array resultsets to cut on the memory usage. If you select a 1000 records and instantiate ORM for every record, memory usage is quite big and oftentimes you only need the results and not the ORM class. This would be optional of course.

Using ORM and some other nifty tricks I was able to put together a full CRUD app in something like 1 hour. The views are the most work in the end. That's where the real performance gain of ORM is.
#12

[eluser]m4rw3r[/eluser]
Ok, I'm terribly sorry, I made an error when I was testing my ORM. I thought I had both models set to has_many (in thread) and belongs_to (in post), but instead I had a has_and_belongs_to_many in the post model :red: .
So that's not really a fair competition, a belongs_to relationship vs a has_and_belongs_to_many relationship (one more query and a little more PHP).

So I remade the test:
The same code as last time (except the change of the post model):

Code:
ORM        5.0832
CI AR      4.8359

Result: My code is about only 5.11 % slower!! :-) (A great increase in performance, really shows the difference between has_many and has_and_belongs_to_many)

While I was at it, I made a test of memory consumption:
The same code, but commented the one I wasn't testing, then I copied the value from the profiler.

Code:
ORM      2,612,520 bytes
CI AR    2,223,888 bytes

Result: My ORM uses about 17.47 % more memory (400 kb more, I think that can be lowered by using more references, but some of that memory are for the compiled classes, I believe)

BTW, This model works like a factory, where all child classes have a reference to the object who created them, by using that pattern I only have one model for many records and not much in the actual ORM_records (a few methods, the row data, uid and related objects (when they are loaded)).

So, now I have to work on the behaviours (suggestions, ideas, etc. are welcome).
#13

[eluser]m4rw3r[/eluser]
I have now almost finished the implementation of Act As and the tree behaviour (using MPTtree).

The acts work like classes that are instantiated as properties of the ORM class, they can add their code on the hooks I've added throughout the find/update/save/delete functions, and they can add child class helpers.
The child class helpers are instantiated for every child object and assigned to a property on the child object, the helpers have a reference to the child to which they are assigned to so they can communicate with the record, ORM class and the act objects.
To make it easier for PHP 5, I will include a commented __call() function, which aggregates the acts into the ORM class and aggregates the child class helpers into the child class.

And now I am wondering how to make a good revision behaviour, how should I store the revision information in the db? and how to make it integrate well with other behaviours (that feature can be scrapped if it doesn't work)?

@xwero: What metadata? The relations? They are stored in the db, and they are defined in pure PHP, so I don't really see anything that needs to be saved in files.

Still sorry about the mistake when I measured the performance, but I'm happy that it didn't become slower (100% slower or something would have been horrible).
#14

[eluser]MMCCQQ[/eluser]
can you write an example with view , controller and model?
#15

[eluser]m4rw3r[/eluser]
Not for the moment, the RC 2 (or more likely the 0.1) is taking much of my time.
When I release version 0.1 I hope that I will have a manual ready (it will probably not be covering everything about the ORM class from the start, I will develop it as I develop the ORM), so for the moment you have to read the comments in the file (I know, they lack usage examples).

If anyone has some more suggestions for this class, please post :-)
#16

[eluser]nmweb[/eluser]
Regarding the versioned model: http://trac.akelos.org/browser/plugins/a...sioned.php

Hope it helps, in the svn is also a list,mptt and, adjacency list behaviour available. If you need more inspiration, there are dozens of these kinds of behaviours available for Ruby Smile
#17

[eluser]MMCCQQ[/eluser]
[quote author="m4rw3r" date="1208951938"]Not for the moment, the RC 2 (or more likely the 0.1) is taking much of my time.
When I release version 0.1 I hope that I will have a manual ready (it will probably not be covering everything about the ORM class from the start, I will develop it as I develop the ORM), so for the moment you have to read the comments in the file (I know, they lack usage examples).

If anyone has some more suggestions for this class, please post :-)[/quote]

when?
#18

[eluser]m4rw3r[/eluser]
I have three more methods to be migrated from MPTtree_ORM_node to the ORM_tree_helper, so there is not so much left apart from the manual and some testing (unless I implement the revision behavior).
#19

[eluser]m4rw3r[/eluser]
Anyone have a good idea about what I should call this model?
ORM seems a bit boring (and taken, I believe) and Active Record is also taken, MORM (Martin's ORM %-P ) is too personal.

So any suggestions for a name?
#20

[eluser]nmweb[/eluser]
Ignited Record ?




Theme © iAndrew 2016 - Forum software by © MyBB