public function main()
    {
        $conf = new GeneratorConfig();
        $conf->setBuildProperties($this->getProject()->getProperties());
        $this->setBuildConnections($conf->getBuildConnections());

        if ($this->sqldbmap === null || $this->getSqlDbMap()->exists() === false) {
            throw new BuildException("You haven't provided an sqldbmap, or " . "the one you specified doesn't exist: " . $this->sqldbmap->getPath());
        }

        if ($this->url === null) {
            throw new BuildException("DSN url attribute must be set!");
        }

        // get an ordered list of SQL files to execute
        $databases = $this->getFilesToExecute();

        $this->log(sprintf('Reading SQL files...'));
        foreach ($databases as $database => $files) {
            $statements[$database] = array();
            foreach ($files as $fileName) {
                $fullFileName = $this->srcDir ? $this->srcDir . DIRECTORY_SEPARATOR . $fileName : $fileName;
                if (file_exists($fullFileName)) {
                    $this->log(sprintf('  Loading statements from "%s"', $fullFileName));
                    $fileStatements = PropelSQLParser::parseFile($fullFileName);
                    $this->log(sprintf('    %d statements to execute', count($fileStatements)), Project::MSG_VERBOSE);
                    $statements[$database] = array_merge($statements[$database], $fileStatements);
                } else {
                    $this->log(sprintf('File "%s" in sqldbmap does not exist, skipping it.', $fullFileName));
                }
            }
        }

        $successfulStatements = 0;
        $this->log(sprintf('Executing SQL statements...'));
        foreach ($statements as $database => $statementList) {
            $successfulStatements += $this->insertDatabaseSqlFiles($database, $statementList);
        }

        $this->log(sprintf('SQL execution complete. %d statements successfully executed.', $successfulStatements));
    }
public function main()
    {
        $conf = new GeneratorConfig();
        $conf->setBuildProperties($this->getProject()->getProperties());
        $this->setBuildConnections($conf->getBuildConnections());

        if ($this->sqldbmap === null || $this->getSqlDbMap()->exists() === false) {
            throw new BuildException("You haven't provided an sqldbmap, or " . "the one you specified doesn't exist: " . $this->sqldbmap->getPath());
        }

        if ($this->url === null) {
            throw new BuildException("DSN url attribute must be set!");
        }

        // get an ordered list of SQL files to execute
        $databases = $this->getFilesToExecute();

        $this->log(sprintf('Reading SQL files...'));
        foreach ($databases as $database => $files) {
            $statements[$database] = array();
            foreach ($files as $fileName) {
                $fullFileName = $this->srcDir ? $this->srcDir . DIRECTORY_SEPARATOR . $fileName : $fileName;
                if (file_exists($fullFileName)) {
                    $this->log(sprintf('  Loading statements from "%s"', $fullFileName));
                    $fileStatements = PropelSQLParser::parseFile($fullFileName);
                    $this->log(sprintf('    %d statements to execute', count($fileStatements)), Project::MSG_VERBOSE);
                    $statements[$database] = array_merge($statements[$database], $fileStatements);
                } else {
                    $this->log(sprintf('File "%s" in sqldbmap does not exist, skipping it.', $fullFileName));
                }
            }
        }

        $successfulStatements = 0;
        $this->log(sprintf('Executing SQL statements...'));
        foreach ($statements as $database => $statementList) {
            $successfulStatements += $this->insertDatabaseSqlFiles($database, $statementList);
        }

        $this->log(sprintf('SQL execution complete. %d statements successfully executed.', $successfulStatements));
    }
public function main ( ) { $ conf = new GeneratorConfig ( ) ; $ conf -> setBuildProperties ( $ this -> getProject ( ) -> getProperties ( ) ) ; $ this -> setBuildConnections ( $ conf -> getBuildConnections ( ) ) ; if ( $ this -> sqldbmap === null || $ this -> getSqlDbMap ( ) -> exists ( ) === false ) { throw new BuildException ( "You haven't provided an sqldbmap, or " . "the one you specified doesn't exist: " . $ this -> sqldbmap -> getPath ( ) ) ; } if ( $ this -> url === null ) { throw new BuildException ( "DSN url attribute must be set!" ) ; } // get an ordered list of SQL files to execute $ databases = $ this -> getFilesToExecute ( ) ; $ this -> log ( sprintf ( 'Reading SQL files...' ) ) ; foreach ( $ databases as $ database => $ files ) { $ statements [ $ database ] = array ( ) ; foreach ( $ files as $ fileName ) { $ fullFileName = $ this -> srcDir ? $ this -> srcDir . DIRECTORY_SEPARATOR . $ fileName : $ fileName ; if ( file_exists ( $ fullFileName ) ) { $ this -> log ( sprintf ( '  Loading statements from "%s"' , $ fullFileName ) ) ; $ fileStatements = PropelSQLParser :: parseFile ( $ fullFileName ) ; $ this -> log ( sprintf ( '    %d statements to execute' , count ( $ fileStatements ) ) , Project :: MSG_VERBOSE ) ; $ statements [ $ database ] = array_merge ( $ statements [ $ database ] , $ fileStatements ) ; } else { $ this -> log ( sprintf ( 'File "%s" in sqldbmap does not exist, skipping it.' , $ fullFileName ) ) ; } } } $ successfulStatements = 0 ; $ this -> log ( sprintf ( 'Executing SQL statements...' ) ) ; foreach ( $ statements as $ database => $ statementList ) { $ successfulStatements += $ this -> insertDatabaseSqlFiles ( $ database , $ statementList ) ; } $ this -> log ( sprintf ( 'SQL execution complete. %d statements successfully executed.' , $ successfulStatements ) ) ; }
Load the sql file and then execute it

@throws BuildException
Load the sql file and then execute it