Simply get the two most recent records

Hi everyone, I'm confused, I do the normal

$items = get_records('Item', array() ,2);
foreach($items as $item){
set_current_record('item', $item);
......

To get the two most recent items.
However, it returns me the first two items entered.
filter & ordering param are not clear to me in omeka 2 documentation

Any clue ?

Cheers

Alex

Hmm, yeah, the documentation there is not great, because the things you can sort by are different for each type of record.

Generally, sorting parameters go in the array that's the second argument to get_records, and use the keys sort_field and sort_dir. A good rule of thumb is that you can usually sort by any basic field of the model (i.e., the columns of the table).

In this case, array('sort_field' => 'added', 'sort_dir' => 'd') should work for "recent first" ordering.

Excellent, thanks a lot

Works great, thanks a lot