PHP-MySQLi-Database-Class
PHP-MySQLi-Database-Class copied to clipboard
Request: Union and Union All
What about add a method union() (and/or unionAll)? May be like this:
$query_1 = $db->addUnion();
$query_1->where('...', '...')->get('table_1');
$query_2 = $db->addUnion();
$query_2->where('...', '...')->get('table_2');
$result = $db->fromUnions($query_1, $query_2)->orderBy('common_field')->get();
Hi , yeah i'am interesting too! It will be usefull! Thank's.
i think we can do that with a subqueries.
$q1 = $db->subQuery();
$q1->get ("users");
$q2 = $db->subQuery();
$q2->get ("clients");
$res = $db->union([$q1, $2]') ->orderBy('common_field')->get();
$res = $db->unionAll([$q1, $2]') ->orderBy('common_field')->get();
@avbdr TIL there is a union function, that's pretty handy.
Edit: Nvm, can't seem to find it