Loading src/UnicaenOracle/Service/DataService.php +20 −9 Original line number Diff line number Diff line Loading @@ -80,16 +80,27 @@ class DataService */ function generateSQLForTablesColumnsInfos(array $tableNames) { $tables = implode(',', array_map(function ($tn) { return "'$tn'"; }, $tableNames)); return <<<EOS select table_name, column_name, data_type from all_tab_columns where table_name in ($tables) order by column_id // Attention, bricolage pour respecter l'ordre des tables fournies ! $i = 0; $sqlParts = array_map(function($name) use ($i) { return sprintf( "select %d as table_order, table_name, column_name, column_id, data_type from all_tab_columns where table_name = '%s'", ++$i, $name); }, $tableNames); $unions = implode( PHP_EOL . 'union all' . PHP_EOL, $sqlParts); $template = <<<EOS select * from ( %s ) order by table_order, column_id EOS; return sprintf($template, $unions); } /** Loading Loading
src/UnicaenOracle/Service/DataService.php +20 −9 Original line number Diff line number Diff line Loading @@ -80,16 +80,27 @@ class DataService */ function generateSQLForTablesColumnsInfos(array $tableNames) { $tables = implode(',', array_map(function ($tn) { return "'$tn'"; }, $tableNames)); return <<<EOS select table_name, column_name, data_type from all_tab_columns where table_name in ($tables) order by column_id // Attention, bricolage pour respecter l'ordre des tables fournies ! $i = 0; $sqlParts = array_map(function($name) use ($i) { return sprintf( "select %d as table_order, table_name, column_name, column_id, data_type from all_tab_columns where table_name = '%s'", ++$i, $name); }, $tableNames); $unions = implode( PHP_EOL . 'union all' . PHP_EOL, $sqlParts); $template = <<<EOS select * from ( %s ) order by table_order, column_id EOS; return sprintf($template, $unions); } /** Loading