private function migrateAuthors()
    {
        /** @var SQLSelect $query */
        $query = SQLSelect::create();
        $query->setSelect('Author')
            ->setFrom('News')
            ->setDistinct(true);
        $authors = $query->execute();
        foreach ($authors as $author) {
            /** Create a new author if it doesn't exist */
            if (!$authorHelper = AuthorHelper::get()->filter(array('OriginalName' => trim($author['Author'])))->first()) {
                /** @var AuthorHelper $authorHelper */
                $authorHelper = AuthorHelper::create();
                $authorHelper->OriginalName = $author['Author'];
                $authorHelper->write();
            }
            $sql = "UPDATE `News` SET `AuthorHelperID` = '" . $authorHelper->ID . "' WHERE Author = '" . $author['Author'] . "'";
            DB::query($sql);
        }
    }
private function migrateAuthors()
    {
        /** @var SQLSelect $query */
        $query = SQLSelect::create();
        $query->setSelect('Author')
            ->setFrom('News')
            ->setDistinct(true);
        $authors = $query->execute();
        foreach ($authors as $author) {
            /** Create a new author if it doesn't exist */
            if (!$authorHelper = AuthorHelper::get()->filter(array('OriginalName' => trim($author['Author'])))->first()) {
                /** @var AuthorHelper $authorHelper */
                $authorHelper = AuthorHelper::create();
                $authorHelper->OriginalName = $author['Author'];
                $authorHelper->write();
            }
            $sql = "UPDATE `News` SET `AuthorHelperID` = '" . $authorHelper->ID . "' WHERE Author = '" . $author['Author'] . "'";
            DB::query($sql);
        }
    }
private function migrateAuthors ( ) { /** @var SQLSelect $query */ $ query = SQLSelect :: create ( ) ; $ query -> setSelect ( 'Author' ) -> setFrom ( 'News' ) -> setDistinct ( true ) ; $ authors = $ query -> execute ( ) ; foreach ( $ authors as $ author ) { /** Create a new author if it doesn't exist */ if ( ! $ authorHelper = AuthorHelper :: get ( ) -> filter ( array ( 'OriginalName' => trim ( $ author [ 'Author' ] ) ) ) -> first ( ) ) { /** @var AuthorHelper $authorHelper */ $ authorHelper = AuthorHelper :: create ( ) ; $ authorHelper -> OriginalName = $ author [ 'Author' ] ; $ authorHelper -> write ( ) ; } $ sql = "UPDATE `News` SET `AuthorHelperID` = '" . $ authorHelper -> ID . "' WHERE Author = '" . $ author [ 'Author' ] . "'" ; DB :: query ( $ sql ) ; } }
For each author, add an AuthorHelper
For each author add an AuthorHelper