protected function runSql($file, $message, $notFoundMessage, $output)
    {
        if (! is_file($file)) {
            $output->writeln($notFoundMessage);

            return;
        }

        $output->writeln($message);

        $dataSql = file_get_contents($file);

        // Split the sql file on new lines and insert into the database one line at a time
        foreach (preg_split('/;\s*\n/', $dataSql) as $command) {
            try {
                $query = $this->db->query($command, DbAdapter::QUERY_MODE_EXECUTE);
            } catch (Database_Exception $e) {
                if ($e->getCode() !== 1065) { // empty query
                    throw $e;
                }
            }
        }
    }
protected function runSql($file, $message, $notFoundMessage, $output)
    {
        if (! is_file($file)) {
            $output->writeln($notFoundMessage);

            return;
        }

        $output->writeln($message);

        $dataSql = file_get_contents($file);

        // Split the sql file on new lines and insert into the database one line at a time
        foreach (preg_split('/;\s*\n/', $dataSql) as $command) {
            try {
                $query = $this->db->query($command, DbAdapter::QUERY_MODE_EXECUTE);
            } catch (Database_Exception $e) {
                if ($e->getCode() !== 1065) { // empty query
                    throw $e;
                }
            }
        }
    }
protected function runSql ( $ file , $ message , $ notFoundMessage , $ output ) { if ( ! is_file ( $ file ) ) { $ output -> writeln ( $ notFoundMessage ) ; return ; } $ output -> writeln ( $ message ) ; $ dataSql = file_get_contents ( $ file ) ; // Split the sql file on new lines and insert into the database one line at a time foreach ( preg_split ( '/;\s*\n/' , $ dataSql ) as $ command ) { try { $ query = $ this -> db -> query ( $ command , DbAdapter :: QUERY_MODE_EXECUTE ) ; } catch ( Database_Exception $ e ) { if ( $ e -> getCode ( ) !== 1065 ) { // empty query throw $ e ; } } } }
Given a filepath to a SQL file, load it and run the SQL statements inside

@param  string $file            Path to SQL file
@param  string $message         Message to output to the console if the file exists
@param  string $notFoundMessage Message to output to the console if the file does not exist
Given a filepath to a SQL file load it and run the SQL statements inside