Hello,

I can select list of all article but without the newest article. I know how select article but i do not know how exclude the newest article.

My code:

$query = db_select('node', 'n')->extend('PagerDefault');
		$query->join('field_data_body', 'fdb', 'fdb.revision_id=n.nid');
		$query
			->condition('status',1)
			->condition('type','article')
			->fields('n', array('nid','type','title','status','created'))
			->fields('fdb', array('revision_id','body_value','body_summary'))
			->orderBy('created','DESC')
			->limit($limit);
		$result = $query->execute();

Please help me.

Comments

fndtn357’s picture

I would suggest creating a view similar to yours in the views UI and checking the code produced, then introduce an offset to that view item amount and check again at the code produced. It might lead in the right direction.

vasi1186’s picture

You can try this:

<?php
$query = db_select('node', 'n')->extend('PagerDefault');
        $query->join('field_data_body', 'fdb', 'fdb.revision_id=n.nid');
        $query
            ->condition('status',1)
            ->condition('type','article')
            ->fields('n', array('nid','type','title','status','created'))
            ->fields('fdb', array('revision_id','body_value','body_summary'))
            ->orderBy('created','DESC')
            ->range(1, $limit);
        $result = $query->execute();
?>

http://drupal.org/node/310075#ranges_and_limits

Vasi.