Welcome Guest, Not a member yet? Register   Sign In
CI + DataMapper + sort relationships
#1

[eluser]chrisloki[/eluser]
Hi guys,

I'm quite new in the "CI" world, though I have some experience with frameworks.

I'm using DataMapper ORM with CI in order to do some tasks, and I have to do something I couldn't achieve with.
Imagine two models, A and B. A has a has_many relationship to B:

function A extends DataMapper {
var $has_many = array("B");
}

I created the intermediate table A_B, and the relationship is working fine.
I can sort the list of B's by any field, but I need to rearrange it in other order.
By example, i have an category and it has a list of posts. How could I sort the lists of posts?

With (the ORM) Hibernate in Java, I can crate in the intermediate table a new field (I usually call it element_position) which I use to set the position/order, and there I do some like this:

A_id | B_id | element_position
1 | 1 | 0
1 | 2 | 2
1 | 3 | 1


Does anyone have an idea of how to implement this with DataMapper?

[]s!


Messages In This Thread
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 08:13 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 08:53 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 10:09 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 10:20 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 10:31 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 11:12 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 04:42 PM
CI + DataMapper + sort relationships - by El Forum - 11-09-2009, 06:32 PM
CI + DataMapper + sort relationships - by El Forum - 11-09-2009, 07:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB