In my Drupal 7
website, I am using views_get_view_result
function to get some details from the database.
Right now I am calling the function like below
$table_data = views_get_view_result('test_tracking', 'block', <nid>);
And this function is calling through ajax
I am now able to get this as an array of objects. But I don't want to get all the data at a time. Is there any way to fetch data with count? So that I will be able to get the slice of the array. I don't want to use array_slice
in PHP. Because it will fetch all the data first and then slice it.
I checked the Official doc but it didn't help.
Is there any way to do this?
To fetch data with limit and offset,
$table_data = views_get_view('test_tracking');
$table_data->set_display('block');
$table_data->set_current_page(3);
$table_data->set_items_per_page(10);
$table_data->pre_execute();
$table_data->execute();
//To render
print $table_data->render();
// To get the result object
$objects = $table_data->result;