/**
  * Execute the specified SQL/commands on the database.
  *
  * @param string $sql The SQL/command to send to the database.
  *
  * @return mixed string or array of returned data, or false on failure
  */
 public function execute($sql)
 {
     $output = false;
     // Check/execute macros
     foreach ($this->_macros[$this->_db_type] as $pattern => $replacement) {
         $c = 0;
         $sql = str_replace($pattern, $replacement, $sql, $c);
         if ($c > 0) {
             break;
         }
     }
     // Strip semicolon from end if its Oracle
     if ($this->_db_type == 'oci') {
         $sql = mb_substr($sql, 0, mb_strlen($sql) - 1);
     }
     // Check what kind of query it is
     $query_type = $this->_getQueryType($sql);
     switch ($query_type) {
         case "SELECT":
             $output = MatrixDAL::executeSqlAssoc($sql);
             break;
         case "UPDATE":
         case "INSERT":
             $rows_affected = MatrixDAL::executeSql($sql);
             $output = $query_type . " " . $rows_affected;
             break;
         case "BEGIN":
             /* There is no return bool code, but according to PHP docs an exception will
                be thrown if the DB doesn't support transactions */
             MatrixDAL::beginTransaction();
             $output = $query_type;
             break;
         case "ROLLBACK":
             MatrixDAL::rollBack();
             $output = $query_type;
             break;
         case "COMMIT":
             MatrixDAL::commit();
             $output = $query_type;
             break;
         default:
             //echo "WARNING: Query type not recognised.\n";
             $output = MatrixDAL::executeSqlAssoc($sql);
             break;
     }
     return $output;
 }
             $data_value = stream_get_contents($stream);
             fclose($stream);
         }
         MatrixDAL::bindValueToPdo($prepared_sql, $data_key, $data_value);
     }
     MatrixDAL::execPdoQuery($prepared_sql);
     $trans_count++;
     if ($trans_count % 10000 == 0) {
         MatrixDAL::commit();
         MatrixDAL::beginTransaction();
         $trans_count = 0;
     }
 }
 printName('Inserting Data (' . number_format($start) . ' - ' . number_format($start + $count) . ' rows)');
 printUpdateStatus('OK', "\r");
 MatrixDAL::commit();
 /**
  * Switch to the source db connector to get the data..
  */
 MatrixDAL::changeDb($source_db);
 /**
  * we got less than the limit?
  * no point hitting the db again, we won't get anything.
  */
 if (count($source_data) < $num_to_fetch) {
     break;
 }
 $start += $num_to_fetch;
 $fetch_source_sql = db_extras_modify_limit_clause($source_sql, $source_dsn['type'], $num_to_fetch, $start);
 $source_data = MatrixDAL::executeSqlAll($fetch_source_sql);
 $count = count($source_data);