Модуль позволяет объединять ORM объекты посредствам SQL UNION ALL запроса
https://github.com/Invision70/kohana-orm-unionМеньше слов, взгляните на код
$order = ORM::factory('Order')->where('user_id', '=', 1);
$forwarding = ORM::factory('Forwarding')->where('user_id', '=', 1);
// initial arguments: (union ORM objects, select columns for SQL UNION ALL)
$union = ORM_Union::initial([$order, $forwarding], ['created'])->order_by('created', 'desc'); // Query Builder for SQL UNION ALL
$total = $union->count_all();
$result = $union->limit(10)->find_all();
foreach ($result as $object)
{
var_dump(get_class($object)); // ORM loaded object
}
// result
string(11) "Model_Order"
string(16) "Model_Forwarding"
string(11) "Model_Order"
string(11) "Model_Order"
string(11) "Model_Order"
string(16) "Model_Forwarding"
string(11) "Model_Order"
string(16) "Model_Forwarding"
string(16) "Model_Forwarding"
string(11) "Model_Order"
// 4 SQL query (3 without count_all)