fetchAll('SELECT * FROM tiki_links WHERE reltype IS NOT NULL'); foreach ($results as $row) { $reltypes = array_filter(explode(',', $row['reltype'])); foreach ($reltypes as $type) { $installer->query( 'INSERT INTO tiki_object_relations (relation, source_type, source_itemId, target_type, target_itemId) VALUES(?, ?, ?, ?, ?)', [ 'tiki.link.' . $type, 'wiki page', $row['fromPage'], 'wiki page', $row['toPage'], ] ); } } }