Alter Views query limit using views_query_alter I want to alter the limit of view using views_query_alter hook.

My code is :

function track_click_views_query_alter(&amp;$view, &amp;$query) {
  if($view-&gt;name == "click_list_days"){
  $w_count = count($query-&gt;where[0]['clauses']) - 1;
  $w_clause = array();
  for($i=0; $i &lt;= $w_count; $i++) {
      $w_clause[] = "(".$query-&gt;where[0]['clauses'][$i].")";
      if($i &gt; 0)
          unset ($query-&gt;where[0]['clauses'][$i]);
  }
  $w_clause = implode(" AND ", $w_clause)." Group By track_click.article_title ";
  $query-&gt;where[0]['clauses'][0] = $w_clause;
  }
}


How can I alter the limit of this views query? I didn't understand which query object i have to alter.
If it's only about the number of results to return, I think you could simply implement hook_views_pre_build() and do the following:

function track_click_views_pre_build(&amp;$view) {
  if ($view-&gt;name == 'click_list_days') {
    $view-&gt;set_items_per_page(YOUR_NUMBER_OF_RESULTS_HERE);
  }
}


Or inside hook_views_query_alter() you should be able to do:

$query-&gt;set_limit(LIMIT);