original_string: public function runScript(array $data, $includeResultSets = false)
      {
          $results = array();
          if ($data['script']) {
              $queries = \MUtil_Parser_Sql_WordsParser::splitStatements($data['script'], false);
              $qCount  = count($queries);
  
              $results[] = sprintf($this->_('Executed %2$s creation script %1$s:'), $data['name'], $this->_(strtolower($data['type'])));
              $stepCount = 1;
              $resultSet = 1;
  
              foreach ($queries as $query) {
                  $sql = (string) $query;
                  try {
                      if (isset($data['db'])) {
                          $db = $data['db'];
                      } else {
                          $db = $this->defaultDb;
  
                          // Lookup using location
                          if (isset($data['location'])) {
                              foreach ($this->directories as $path) {
                                  if ($path['name'] === $data['location']) {
                                      $db = $path['db'];
                                      break;
                                  }
                              }
                          }
                      }
                      $stmt = $db->query($sql);
                      if ($rows = $stmt->rowCount()) {
                          if ($includeResultSets && ($data = $stmt->fetchAll())) {
                              $results[] = sprintf($this->_('%d record(s) returned as result set %d in step %d of %d.'), $rows, $resultSet, $stepCount, $qCount);
                              $results[] = $data;
                              $resultSet++;
                          } else {
                              $results[] = sprintf($this->_('%d record(s) updated in step %d of %d.'), $rows, $stepCount, $qCount);
                          }
                      } else {
                          $results[] = sprintf($this->_('Script ran step %d of %d succesfully.'), $stepCount, $qCount);
                      }
                  } catch (\Zend_Db_Statement_Exception $e) {
                      $results[] = $e->getMessage() . $this->_('  in step ') . $stepCount . ': ' . $sql;
                  }
                  $stepCount++;
              }
          } else {
              $results[] = sprintf($this->_('No script for %1$s.'), $data['name']);
          }
  
          return $results;
      }
code: public function runScript(array $data, $includeResultSets = false)
      {
          $results = array();
          if ($data['script']) {
              $queries = \MUtil_Parser_Sql_WordsParser::splitStatements($data['script'], false);
              $qCount  = count($queries);
  
              $results[] = sprintf($this->_('Executed %2$s creation script %1$s:'), $data['name'], $this->_(strtolower($data['type'])));
              $stepCount = 1;
              $resultSet = 1;
  
              foreach ($queries as $query) {
                  $sql = (string) $query;
                  try {
                      if (isset($data['db'])) {
                          $db = $data['db'];
                      } else {
                          $db = $this->defaultDb;
  
                          // Lookup using location
                          if (isset($data['location'])) {
                              foreach ($this->directories as $path) {
                                  if ($path['name'] === $data['location']) {
                                      $db = $path['db'];
                                      break;
                                  }
                              }
                          }
                      }
                      $stmt = $db->query($sql);
                      if ($rows = $stmt->rowCount()) {
                          if ($includeResultSets && ($data = $stmt->fetchAll())) {
                              $results[] = sprintf($this->_('%d record(s) returned as result set %d in step %d of %d.'), $rows, $resultSet, $stepCount, $qCount);
                              $results[] = $data;
                              $resultSet++;
                          } else {
                              $results[] = sprintf($this->_('%d record(s) updated in step %d of %d.'), $rows, $stepCount, $qCount);
                          }
                      } else {
                          $results[] = sprintf($this->_('Script ran step %d of %d succesfully.'), $stepCount, $qCount);
                      }
                  } catch (\Zend_Db_Statement_Exception $e) {
                      $results[] = $e->getMessage() . $this->_('  in step ') . $stepCount . ': ' . $sql;
                  }
                  $stepCount++;
              }
          } else {
              $results[] = sprintf($this->_('No script for %1$s.'), $data['name']);
          }
  
          return $results;
      }
code_tokens: public function runScript ( array $ data , $ includeResultSets = false ) { $ results = array ( ) ; if ( $ data [ 'script' ] ) { $ queries = \ MUtil_Parser_Sql_WordsParser :: splitStatements ( $ data [ 'script' ] , false ) ; $ qCount = count ( $ queries ) ; $ results [ ] = sprintf ( $ this -> _ ( 'Executed %2$s creation script %1$s:' ) , $ data [ 'name' ] , $ this -> _ ( strtolower ( $ data [ 'type' ] ) ) ) ; $ stepCount = 1 ; $ resultSet = 1 ; foreach ( $ queries as $ query ) { $ sql = ( string ) $ query ; try { if ( isset ( $ data [ 'db' ] ) ) { $ db = $ data [ 'db' ] ; } else { $ db = $ this -> defaultDb ; // Lookup using location if ( isset ( $ data [ 'location' ] ) ) { foreach ( $ this -> directories as $ path ) { if ( $ path [ 'name' ] === $ data [ 'location' ] ) { $ db = $ path [ 'db' ] ; break ; } } } } $ stmt = $ db -> query ( $ sql ) ; if ( $ rows = $ stmt -> rowCount ( ) ) { if ( $ includeResultSets && ( $ data = $ stmt -> fetchAll ( ) ) ) { $ results [ ] = sprintf ( $ this -> _ ( '%d record(s) returned as result set %d in step %d of %d.' ) , $ rows , $ resultSet , $ stepCount , $ qCount ) ; $ results [ ] = $ data ; $ resultSet ++ ; } else { $ results [ ] = sprintf ( $ this -> _ ( '%d record(s) updated in step %d of %d.' ) , $ rows , $ stepCount , $ qCount ) ; } } else { $ results [ ] = sprintf ( $ this -> _ ( 'Script ran step %d of %d succesfully.' ) , $ stepCount , $ qCount ) ; } } catch ( \ Zend_Db_Statement_Exception $ e ) { $ results [ ] = $ e -> getMessage ( ) . $ this -> _ ( '  in step ' ) . $ stepCount . ': ' . $ sql ; } $ stepCount ++ ; } } else { $ results [ ] = sprintf ( $ this -> _ ( 'No script for %1$s.' ) , $ data [ 'name' ] ) ; } return $ results ; }
docstring: Run a sql statement from an object loaded through this model
  
  $data is an array with the following keys:
  script   The sql statement to be executed
  name     The name of the table, used in messages
  type     Type of db element (table or view), used in messages
  
  @param array $data
  @param boolean $includeResultSets
  @return string
docstring_tokens: Run a sql statement from an object loaded through this model