3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 346 Views |
-
DataObject::get() - all but latest

27 September 2011 at 7:19pm
Hello,
as the title says, I need to form a DataObject::get() query with filter so that it gets all of the objects in a table except the latest entry, which is shown in a different place (so there is no repeat).Thank you all!
-
Re: DataObject::get() - all but latest

28 September 2011 at 1:00am
After you retrieved the latest, you could use its ID to filter the others, as in "where ID IS NOT $LatestID"...
-
Re: DataObject::get() - all but latest

28 September 2011 at 9:02am
What I would do is use DataObject::get with a Created DESC filter then use array_splice to knock off the last or first item.
-
Re: DataObject::get() - all but latest

28 September 2011 at 8:42pm Last edited: 28 September 2011 9:47pm
Yeah, well the thing is it is a list of DataObjects where there are DataObjects constantly being added so the ID of the latest object is constantly changing and I don't see it as a good solution.
Array_slice might work, I will try that.
The thing is, what I've seen be4, there is a way to do it through limit field. I've been using it be4 in a way that first argument is the number of objects you wanna skip and then the second argument is the number of them you wanna take after you skip the first number of objects.
The pagination is working in exactly the same way. So, since I AM actually going to use pagination for them, I thougth it would be enough to set $SQL_start = 1 and then it should skip the first one (being $SQL_start = 0) and use the next 14 and then it should work well from there on. For some reason putting function getObjects ($SQL_start = 1, $paginLimit = 14) {... doesn't do it, tbh I don't understand why.Be4, as I have said, in another function - let's call it:
function getOtherObjects ($skip, $num) {
$kr = DataObject::get_one("Holder");
$objects = ($kr) ? DataObject::get("myDataObject", "ParentID = $kr->ID", "Date DESC", "", $skip.','.$num) : false;
return $objects;
}it worked... I am not sure what is going on here.
EDIT: come to think of it, wouldn't array slice do the same thing with every pagionation section? wouldn't it leave out the latest dataobject on every page?
| 346 Views | ||
|
Page:
1
|
Go to Top |


