Initialize(); $dbCodeStore = $session->getDatabase( "", "prominic/codestore/store.nsf" ); $vwArticles = $dbCodeStore->getView( "area" ); if( !$vwArticles ) { die("Unable to get view"); } $docArticle = $vwArticles->getFirstDocument(); while( $docArticle ) { $datetmp = $docArticle->getFirstItem("Published"); $datebits = explode("/", $datetmp->Text ); $datestr = $datebits[2]."-".$datebits[1]."-".$datebits[0]; echo "INSERT INTO articles VALUES ('', "; echo "'".getItemValueString( $docArticle, "ThreadID" )."', "; echo "'".getItemValueString( $docArticle, "Area" )."', "; echo "'".$datestr."', "; echo "'".addslashes(getItemValueString( $docArticle, "Title"))."', "; echo "'".addslashes(format_output(getItemValueString( $docArticle, "Body")))."');"; echo "\n"; $docArticle = $vwArticles->getNextDocument( $docArticle ); } function format_output($output) { $output = htmlspecialchars(stripslashes($output)); $output = str_replace('[<', '<', $output); $output = str_replace('>]', '>', $output); $output = str_replace('"', '"', $output); return nl2br($output); } # Helper function to get the first value in the given field function getItemValueString( $doc, $field ) { $value = $doc->getItemValue($field); return $value[0]; } ?>