method selectUnion documentation in bbn\Db

function(array $union, array $fields = [], array $where = [], array $order = [], int $start = 0) { $cfgs = []; $sql = 'SELECT '; if (empty($fields)) { $sql .= '* '; } else{ foreach ($fields as $i => $f){ if ($i) { $sql .= ', '; } $sql .= $this->csn($f, true); } } $sql .= ' FROM (('.PHP_EOL; $vals = []; $i = 0; foreach ($union as $u){ $cfg = $this->processCfg($this->_add_kind([$u])); if ($cfg && $cfg['sql']) { /** @todo From here needs to analyze the where array to the light of the tables' config */ if (!empty($where)) { if (empty($fields)) { $fields = $cfg['fields']; } foreach ($fields as $k => $f){ if (isset($cfg['available_fields'][$f])) { if ($cfg['available_fields'][$f] && ($t = $cfg['models'][$cfg['available_fields'][$f]]) ) { throw new Exception("Impossible to create the where in union for the following request: ".PHP_EOL.$cfg['sql']); //die(var_dump($t['fields'][$cfg['fields'][$f] ?? $this->csn($f)])); } } } } if ($i) { $sql .= PHP_EOL.') UNION ('.PHP_EOL; } $sql .= $cfg['sql']; foreach ($cfg['values'] as $v){ $vals[] = $v; } $i++; } } $sql .= PHP_EOL.')) AS t'; return $this->getRows($sql, ...$vals); //echo nl2br($sql); return []; }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.