private function migratePages()
    {
        $existquery = "SHOW COLUMNS FROM `News` LIKE 'NewsHolderPageID';";
        /** @var DB $exists */
        $exists = DB::query($existquery);
        if ($count = $exists->numRecords()) {
            /** @var SQLQuery $query */
            $query = new SQLQuery();
            $query->setSelect(array('ID', 'NewsHolderPageID'))
                ->setFrom('News');
            $newsitems = $query->execute();
            foreach ($newsitems as $newsitem) {
                if ($newsitem['NewsHolderPageID'] && NewsHolderPage::get()->byID($newsitem['NewsHolderPageID'])) {
                    News::get()
                        ->byID($newsitem['ID'])
                        ->NewsHolderPages()->add($newsitem['NewsHolderPageID']);
                }
            }
        }
    }
private function migratePages()
    {
        $existquery = "SHOW COLUMNS FROM `News` LIKE 'NewsHolderPageID';";
        /** @var DB $exists */
        $exists = DB::query($existquery);
        if ($count = $exists->numRecords()) {
            /** @var SQLQuery $query */
            $query = new SQLQuery();
            $query->setSelect(array('ID', 'NewsHolderPageID'))
                ->setFrom('News');
            $newsitems = $query->execute();
            foreach ($newsitems as $newsitem) {
                if ($newsitem['NewsHolderPageID'] && NewsHolderPage::get()->byID($newsitem['NewsHolderPageID'])) {
                    News::get()
                        ->byID($newsitem['ID'])
                        ->NewsHolderPages()->add($newsitem['NewsHolderPageID']);
                }
            }
        }
    }
private function migratePages ( ) { $ existquery = "SHOW COLUMNS FROM `News` LIKE 'NewsHolderPageID';" ; /** @var DB $exists */ $ exists = DB :: query ( $ existquery ) ; if ( $ count = $ exists -> numRecords ( ) ) { /** @var SQLQuery $query */ $ query = new SQLQuery ( ) ; $ query -> setSelect ( array ( 'ID' , 'NewsHolderPageID' ) ) -> setFrom ( 'News' ) ; $ newsitems = $ query -> execute ( ) ; foreach ( $ newsitems as $ newsitem ) { if ( $ newsitem [ 'NewsHolderPageID' ] && NewsHolderPage :: get ( ) -> byID ( $ newsitem [ 'NewsHolderPageID' ] ) ) { News :: get ( ) -> byID ( $ newsitem [ 'ID' ] ) -> NewsHolderPages ( ) -> add ( $ newsitem [ 'NewsHolderPageID' ] ) ; } } } }
This is to migrate existing newsitems to the new release with the new relational method.
It is forward-non-destructive.
Only run if there is a column NewsHolderPageID

@todo This needs a rewrite, could be done with less queries with an add Items to Page instead of the current situation.
This is to migrate existing newsitems to the new release with the new relational method . It is forward - non - destructive . Only run if there is a column NewsHolderPageID