1

I am using Drupal 7 and i want to use the Pager into my query

This is my query and the way I can use

$query = db_select("SELECT entity_id , field_keywords_value , COUNT( DISTINCT ( entity_id )) total FROM field_data_field_keywords WHERE bundle = 'song' GROUP BY field_keywords_value");

$query = $query -> extend('PagerDefault'); 
$result = $query -> extend('PagerDefault') ->limit(2) ->execute();

but it give me the error, PDOException: erro

And if I can use it in the following way:

$query = db_query("SELECT entity_id , field_keywords_value , COUNT( DISTINCT ( entity_id )) total FROM field_data_field_keywords WHERE bundle = 'song' GROUP BY field_keywords_value"); 
$query = $query -> extend('PagerDefault'); 
$result = $query ->extend('PagerDefault') ->limit(2) ->execute(); echo ""; print_r($result); die('tert');

Then my page not working and give me the blank page.

Any help will be appreciate.

Thanks in advance.

4

1 回答 1

0

嗨,我已经通过自己解决了这个问题
$query = db_select('field_data_field_keywords')->extend('PagerDefault'); $query->fields('field_data_field_keywords', array('field_keywords_value', 'entity_id')); $query->condition('bundle', 'song'); $query->condition('field_keywords_value', arg(2)); $query->distinct(entity_id); $result = $query ->limit(1) ->execute() ->fetchAll();

谢谢

于 2012-11-02T04:39:43.347 回答