在我的Drupal 7
网站中,我使用views_get_view_result
函数从数据库中获取一些详细信息。
现在我正在调用下面的函数
$table_data = views_get_view_result('test_tracking', 'block', <nid>);
此功能正在通过ajax
进行调用我现在能够将其作为一个对象数组。 但我不想一次获取所有数据。有没有办法用count来获取数据?这样我就能得到数组的切片。我不想在PHP中使用array_slice
。因为它将首先获取所有数据然后对其进行切片。
我检查了Official doc,但没有帮助。
有没有办法做到这一点?
答案 0 :(得分:1)
要获取带限制和偏移量的数据,
$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;