+ /**
+ * Append an SQL fragment to the open file handle.
+ *
+ * @param $filename String: File name to open
+ */
+ public function copyFile( $filename ) {
+ $this->db->sourceFile( $filename, false, false, false,
+ array( $this, 'appendLine' )
+ );
+ }
+
+ /**
+ * Append a line to the open filehandle. The line is assumed to
+ * be a complete SQL statement.
+ *
+ * This is used as a callback for for sourceLine().
+ *
+ * @param $line String text to append to the file
+ * @return Boolean false to skip actually executing the file
+ * @throws MWException
+ */
+ public function appendLine( $line ) {
+ $line = rtrim( $line ) . ";\n";
+ if( fwrite( $this->fileHandle, $line ) === false ) {
+ throw new MWException( "trouble writing file" );
+ }
+ return false;
+ }
+