Example #1
0
/**
 * Outputs the content of a table
 *
 * @param   string      the database name
 * @param   string      the table name
 * @param   string      the end of line sequence
 * @param   string      the url to go back in case of error
 * @param   string      SQL query for obtaining data
 *
 * @return  bool        Whether it suceeded
 *
 * @access  public
 */
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
    $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED);
    $columns_cnt = PMA_DBI_num_fields($result);
    for ($i = 0; $i < $columns_cnt; $i++) {
        $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
    }
    unset($i);
    $buffer = '  <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
    if (!PMA_exportOutputHandler($buffer)) {
        return FALSE;
    }
    while ($record = PMA_DBI_fetch_row($result)) {
        $buffer = '    <' . $table . '>' . $crlf;
        for ($i = 0; $i < $columns_cnt; $i++) {
            if (isset($record[$i]) && !is_null($record[$i])) {
                $buffer .= '        <' . $columns[$i] . '>' . htmlspecialchars($record[$i]) . '</' . $columns[$i] . '>' . $crlf;
            }
        }
        $buffer .= '    </' . $table . '>' . $crlf;
        if (!PMA_exportOutputHandler($buffer)) {
            return FALSE;
        }
    }
    PMA_DBI_free_result($result);
    return TRUE;
}
Example #2
0
/**
 * Outputs the content of a table in CSV format
 *
 * @param   string      the database name
 * @param   string      the table name
 * @param   string      the end of line sequence
 * @param   string      the url to go back in case of error
 * @param   string      SQL query for obtaining data
 *
 * @return  bool        Whether it suceeded
 *
 * @access  public
 */
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
    global $what;
    // Gets the data from the database
    $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
    $fields_cnt = PMA_DBI_num_fields($result);
    // If required, get fields name at the first line
    if (isset($GLOBALS[$what . '_shownames']) && $GLOBALS[$what . '_shownames'] == 'yes') {
        $schema_insert = '<tr>';
        for ($i = 0; $i < $fields_cnt; $i++) {
            $schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
        }
        // end for
        $schema_insert .= '</tr>';
        if (!PMA_exportOutputHandler($schema_insert)) {
            return FALSE;
        }
    }
    // end if
    // Format the data
    while ($row = PMA_DBI_fetch_row($result)) {
        $schema_insert = '<tr>';
        for ($j = 0; $j < $fields_cnt; $j++) {
            if (!isset($row[$j]) || is_null($row[$j])) {
                $value = $GLOBALS[$what . '_replace_null'];
            } elseif ($row[$j] == '0' || $row[$j] != '') {
                $value = $row[$j];
            } else {
                $value = '';
            }
            $schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>';
        }
        // end for
        $schema_insert .= '</tr>';
        if (!PMA_exportOutputHandler($schema_insert)) {
            return FALSE;
        }
    }
    // end while
    PMA_DBI_free_result($result);
    return TRUE;
}
 /**
  * Outputs the content of a table in CSV format
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $what;
     if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strDumpingData'] . ' ' . $table . '</h2>')) {
         return FALSE;
     }
     if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
         return FALSE;
     }
     // Gets the data from the database
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $fields_cnt = PMA_DBI_num_fields($result);
     // If required, get fields name at the first line
     if (isset($GLOBALS['htmlword_columns'])) {
         $schema_insert = '<tr class="print-category">';
         for ($i = 0; $i < $fields_cnt; $i++) {
             $schema_insert .= '<td class="print"><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
         }
         // end for
         $schema_insert .= '</tr>';
         if (!PMA_exportOutputHandler($schema_insert)) {
             return FALSE;
         }
     }
     // end if
     // Format the data
     while ($row = PMA_DBI_fetch_row($result)) {
         $schema_insert = '<tr class="print-category">';
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j]) || is_null($row[$j])) {
                 $value = $GLOBALS[$what . '_null'];
             } elseif ($row[$j] == '0' || $row[$j] != '') {
                 $value = $row[$j];
             } else {
                 $value = '';
             }
             $schema_insert .= '<td class="print">' . htmlspecialchars($value) . '</td>';
         }
         // end for
         $schema_insert .= '</tr>';
         if (!PMA_exportOutputHandler($schema_insert)) {
             return FALSE;
         }
     }
     // end while
     PMA_DBI_free_result($result);
     if (!PMA_exportOutputHandler('</table>')) {
         return FALSE;
     }
     return TRUE;
 }
Example #4
0
 /**
  * Outputs the content of a table in YAML format
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $columns_cnt = PMA_DBI_num_fields($result);
     for ($i = 0; $i < $columns_cnt; $i++) {
         $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
     }
     unset($i);
     $buffer = '';
     $record_cnt = 0;
     while ($record = PMA_DBI_fetch_row($result)) {
         $record_cnt++;
         // Output table name as comment if this is the first record of the table
         if ($record_cnt == 1) {
             $buffer .= $crlf . '// ' . $db . '.' . $table . $crlf;
             $buffer .= '$' . $table . ' = array(' . $crlf;
             $buffer .= '  array(';
         } else {
             $buffer .= ',' . $crlf . '  array(';
         }
         for ($i = 0; $i < $columns_cnt; $i++) {
             $buffer .= "'" . $columns[$i] . "'=>" . var_export($record[$i], true) . ($i + 1 >= $columns_cnt ? '' : ',');
         }
         $buffer .= ')';
     }
     $buffer .= $crlf . ');' . $crlf;
     if (!PMA_exportOutputHandler($buffer)) {
         return FALSE;
     }
     PMA_DBI_free_result($result);
     return true;
 }
Example #5
0
 /**
  * Outputs the content of a table in CSV format
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $what;
     global $workbook;
     $worksheet =& $workbook->addWorksheet($table);
     $workbook->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
     // Gets the data from the database
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $fields_cnt = PMA_DBI_num_fields($result);
     $col = 0;
     // If required, get fields name at the first line
     if (isset($GLOBALS['xls_columns']) && $GLOBALS['xls_columns'] == 'yes') {
         $schema_insert = '';
         for ($i = 0; $i < $fields_cnt; $i++) {
             $worksheet->write(0, $i, stripslashes(PMA_DBI_field_name($result, $i)));
         }
         // end for
         $col++;
     }
     // end if
     // Format the data
     while ($row = PMA_DBI_fetch_row($result)) {
         $schema_insert = '';
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j]) || is_null($row[$j])) {
                 $worksheet->write($col, $j, $GLOBALS['xls_null']);
             } elseif ($row[$j] == '0' || $row[$j] != '') {
                 // FIXME: we should somehow handle character set here!
                 $worksheet->write($col, $j, $row[$j]);
             } else {
                 $worksheet->write($col, $j, '');
             }
         }
         // end for
         $col++;
     }
     // end while
     PMA_DBI_free_result($result);
     return TRUE;
 }
Example #6
0
File: csv.php Project: lifecom/test
/**
 * Outputs the content of a table in CSV format
 *
 * @param   string      the database name
 * @param   string      the table name
 * @param   string      the end of line sequence
 * @param   string      the url to go back in case of error
 * @param   string      SQL query for obtaining data
 *
 * @return  bool        Whether it suceeded
 *
 * @access  public
 */
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
    global $what;
    global $add_character;
    global $separator;
    global $enclosed;
    global $escaped;
    // Gets the data from the database
    $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED);
    $fields_cnt = PMA_DBI_num_fields($result);
    // If required, get fields name at the first line
    if (isset($GLOBALS['showcsvnames']) && $GLOBALS['showcsvnames'] == 'yes') {
        $schema_insert = '';
        for ($i = 0; $i < $fields_cnt; $i++) {
            if ($enclosed == '') {
                $schema_insert .= stripslashes(PMA_DBI_field_name($result, $i));
            } else {
                $schema_insert .= $enclosed . str_replace($enclosed, $escaped . $enclosed, stripslashes(PMA_DBI_field_name($result, $i))) . $enclosed;
            }
            $schema_insert .= $separator;
        }
        // end for
        $schema_insert = trim(substr($schema_insert, 0, -1));
        if (!PMA_exportOutputHandler($schema_insert . $add_character)) {
            return FALSE;
        }
    }
    // end if
    // Format the data
    while ($row = PMA_DBI_fetch_row($result)) {
        $schema_insert = '';
        for ($j = 0; $j < $fields_cnt; $j++) {
            if (!isset($row[$j]) || is_null($row[$j])) {
                $schema_insert .= $GLOBALS[$what . '_replace_null'];
            } else {
                if ($row[$j] == '0' || $row[$j] != '') {
                    // loic1 : always enclose fields
                    if ($what == 'excel') {
                        $row[$j] = ereg_replace("\r(\n)?", "\n", $row[$j]);
                    }
                    if ($enclosed == '') {
                        $schema_insert .= $row[$j];
                    } else {
                        $schema_insert .= $enclosed . str_replace($enclosed, $escaped . $enclosed, $row[$j]) . $enclosed;
                    }
                } else {
                    $schema_insert .= '';
                }
            }
            if ($j < $fields_cnt - 1) {
                $schema_insert .= $separator;
            }
        }
        // end for
        if (!PMA_exportOutputHandler($schema_insert . $add_character)) {
            return FALSE;
        }
    }
    // end while
    PMA_DBI_free_result($result);
    return TRUE;
}
 /**
  * Outputs the content of a table in CSV format
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $what;
     // Gets the data from the database
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $fields_cnt = PMA_DBI_num_fields($result);
     $fields_meta = PMA_DBI_get_fields_meta($result);
     $field_flags = array();
     for ($j = 0; $j < $fields_cnt; $j++) {
         $field_flags[$j] = PMA_DBI_field_flags($result, $j);
     }
     $GLOBALS['ods_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '">';
     // If required, get fields name at the first line
     if (isset($GLOBALS[$what . '_columns'])) {
         $GLOBALS['ods_buffer'] .= '<table:table-row>';
         for ($i = 0; $i < $fields_cnt; $i++) {
             $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>' . '</table:table-cell>';
         }
         // end for
         $GLOBALS['ods_buffer'] .= '</table:table-row>';
     }
     // end if
     // Format the data
     while ($row = PMA_DBI_fetch_row($result)) {
         $GLOBALS['ods_buffer'] .= '<table:table-row>';
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j]) || is_null($row[$j])) {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>' . '</table:table-cell>';
                 // ignore binary field
                 // Note: with mysqli, under MySQL 4.1.3, we get the flag
                 // "binary" for those field types (I don't know why)
             } elseif (stristr($field_flags[$j], 'BINARY') && isset($GLOBALS['sql_hex_for_binary']) && $fields_meta[$j]->type != 'datetime' && $fields_meta[$j]->type != 'date' && $fields_meta[$j]->type != 'time' && $fields_meta[$j]->type != 'timestamp') {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p></text:p>' . '</table:table-cell>';
             } elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
             } else {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
             }
         }
         // end for
         $GLOBALS['ods_buffer'] .= '</table:table-row>';
     }
     // end while
     PMA_DBI_free_result($result);
     $GLOBALS['ods_buffer'] .= '</table:table>';
     return TRUE;
 }
Example #8
0
 /**
  * Outputs the content of a table in XML format
  *
  * @param string $db        database name
  * @param string $table     table name
  * @param string $crlf      the end of line sequence
  * @param string $error_url the url to go back in case of error
  * @param string $sql_query SQL query for obtaining data
  *
  * @return bool Whether it succeeded
  */
 public function exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
         $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
         $columns_cnt = PMA_DBI_num_fields($result);
         $columns = array();
         for ($i = 0; $i < $columns_cnt; $i++) {
             $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
         }
         unset($i);
         $buffer = '        <!-- ' . __('Table') . ' ' . $table . ' -->' . $crlf;
         if (!PMA_exportOutputHandler($buffer)) {
             return false;
         }
         while ($record = PMA_DBI_fetch_row($result)) {
             $buffer = '        <table name="' . htmlspecialchars($table) . '">' . $crlf;
             for ($i = 0; $i < $columns_cnt; $i++) {
                 // If a cell is NULL, still export it to preserve
                 // the XML structure
                 if (!isset($record[$i]) || is_null($record[$i])) {
                     $record[$i] = 'NULL';
                 }
                 $buffer .= '            <column name="' . htmlspecialchars($columns[$i]) . '">' . htmlspecialchars((string) $record[$i]) . '</column>' . $crlf;
             }
             $buffer .= '        </table>' . $crlf;
             if (!PMA_exportOutputHandler($buffer)) {
                 return false;
             }
         }
         PMA_DBI_free_result($result);
     }
     return true;
 }
Example #9
0
 /**
  * Outputs the content of a table in CSV format
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $what;
     global $workbook;
     $workbook->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
     // Gets the data from the database
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $fields_cnt = PMA_DBI_num_fields($result);
     $row = PMA_DBI_fetch_row($result);
     for ($sheetIndex = 0;; $sheetIndex++) {
         // Maximum sheet name length is 31 chars - leave 2 for numeric index
         $sheetName = substr($table, 0, 29) . ($sheetIndex > 0 ? $sheetIndex : '');
         $worksheet =& $workbook->addWorksheet($sheetName);
         $rowIndex = 0;
         // If required, get fields name at the first line
         if (isset($GLOBALS['xls_columns']) && $GLOBALS['xls_columns']) {
             for ($i = 0; $i < $fields_cnt; $i++) {
                 $worksheet->write(0, $i, stripslashes(PMA_DBI_field_name($result, $i)));
             }
             // end for
             $worksheet->repeatRows($rowIndex);
             $worksheet->freezePanes(array($rowIndex + 1, 0, $rowIndex + 1, 0));
             $rowIndex++;
         }
         // end if
         // Format the data (max 65536 rows per worksheet)
         while ($rowIndex < 65536 && $row) {
             set_time_limit(0);
             for ($j = 0; $j < $fields_cnt; $j++) {
                 if (!isset($row[$j]) || is_null($row[$j])) {
                     $worksheet->write($rowIndex, $j, $GLOBALS['xls_null']);
                 } elseif ($row[$j] == '0' || $row[$j] != '') {
                     /**
                      * @todo we should somehow handle character set here!
                      */
                     $worksheet->write($rowIndex, $j, $row[$j]);
                 } else {
                     $worksheet->write($rowIndex, $j, '');
                 }
             }
             // end for
             $rowIndex++;
             $row = PMA_DBI_fetch_row($result);
         }
         // end while
         if (!$row) {
             break;
         }
     }
     // end for
     PMA_DBI_free_result($result);
     return TRUE;
 }
Example #10
0
 /**
  * Outputs the content of a table in YAML format
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $columns_cnt = PMA_DBI_num_fields($result);
     for ($i = 0; $i < $columns_cnt; $i++) {
         $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
     }
     unset($i);
     // fix variable names (based on http://www.php.net/manual/language.variables.basics.php)
     if (preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $table) == false) {
         // fix invalid chars in variable names by replacing them with underscores
         $tablefixed = preg_replace('/[^a-zA-Z0-9_\\x7f-\\xff]/', '_', $table);
         // variable name must not start with a number or dash...
         if (preg_match('/^[a-zA-Z_\\x7f-\\xff]/', $tablefixed) == false) {
             $tablefixed = '_' . $tablefixed;
         }
     } else {
         $tablefixed = $table;
     }
     $buffer = '';
     $record_cnt = 0;
     while ($record = PMA_DBI_fetch_row($result)) {
         $record_cnt++;
         // Output table name as comment if this is the first record of the table
         if ($record_cnt == 1) {
             $buffer .= $crlf . '// ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $crlf;
             $buffer .= '$' . $tablefixed . ' = array(' . $crlf;
             $buffer .= '  array(';
         } else {
             $buffer .= ',' . $crlf . '  array(';
         }
         for ($i = 0; $i < $columns_cnt; $i++) {
             $buffer .= var_export($columns[$i], true) . " => " . var_export($record[$i], true) . ($i + 1 >= $columns_cnt ? '' : ',');
         }
         $buffer .= ')';
     }
     $buffer .= $crlf . ');' . $crlf;
     if (!PMA_exportOutputHandler($buffer)) {
         return FALSE;
     }
     PMA_DBI_free_result($result);
     return true;
 }
Example #11
0
 /**
  * Outputs the content of a table in JSON format
  *
  * @param string $db        database name
  * @param string $table     table name
  * @param string $crlf      the end of line sequence
  * @param string $error_url the url to go back in case of error
  * @param string $sql_query SQL query for obtaining data
  *
  * @return bool Whether it succeeded
  */
 public function exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $columns_cnt = PMA_DBI_num_fields($result);
     // Get field information
     $fields_meta = PMA_DBI_get_fields_meta($result);
     for ($i = 0; $i < $columns_cnt; $i++) {
         $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
     }
     unset($i);
     $buffer = '';
     $record_cnt = 0;
     while ($record = PMA_DBI_fetch_row($result)) {
         $record_cnt++;
         // Output table name as comment if this is the first record of the table
         if ($record_cnt == 1) {
             $buffer .= '// ' . $db . '.' . $table . $crlf . $crlf;
             $buffer .= '[{';
         } else {
             $buffer .= ', {';
         }
         for ($i = 0; $i < $columns_cnt; $i++) {
             $isLastLine = $i + 1 >= $columns_cnt;
             $column = $columns[$i];
             if (is_null($record[$i])) {
                 $buffer .= '"' . addslashes($column) . '": null' . (!$isLastLine ? ',' : '');
             } elseif ($fields_meta[$i]->numeric) {
                 $buffer .= '"' . addslashes($column) . '": ' . $record[$i] . (!$isLastLine ? ',' : '');
             } else {
                 $buffer .= '"' . addslashes($column) . '": "' . addslashes($record[$i]) . '"' . (!$isLastLine ? ',' : '');
             }
         }
         $buffer .= '}';
     }
     if ($record_cnt) {
         $buffer .= ']';
     }
     if (!PMA_exportOutputHandler($buffer)) {
         return false;
     }
     PMA_DBI_free_result($result);
     return true;
 }
Example #12
0
 /**
  * Outputs the content of a table in ODS format
  *
  * @param string  $db         database name
  * @param string  $table      table name
  * @param string  $crlf       the end of line sequence
  * @param string  $error_url  the url to go back in case of error
  * @param string  $sql_query  SQL query for obtaining data
  * @return  bool        Whether it succeeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $what;
     // Gets the data from the database
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $fields_cnt = PMA_DBI_num_fields($result);
     $fields_meta = PMA_DBI_get_fields_meta($result);
     $field_flags = array();
     for ($j = 0; $j < $fields_cnt; $j++) {
         $field_flags[$j] = PMA_DBI_field_flags($result, $j);
     }
     $GLOBALS['ods_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '">';
     // If required, get fields name at the first line
     if (isset($GLOBALS[$what . '_columns'])) {
         $GLOBALS['ods_buffer'] .= '<table:table-row>';
         for ($i = 0; $i < $fields_cnt; $i++) {
             $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>' . '</table:table-cell>';
         }
         // end for
         $GLOBALS['ods_buffer'] .= '</table:table-row>';
     }
     // end if
     // Format the data
     while ($row = PMA_DBI_fetch_row($result)) {
         $GLOBALS['ods_buffer'] .= '<table:table-row>';
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j]) || is_null($row[$j])) {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>' . '</table:table-cell>';
                 // ignore BLOB
             } elseif (stristr($field_flags[$j], 'BINARY') && $fields_meta[$j]->blob) {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p></text:p>' . '</table:table-cell>';
             } elseif ($fields_meta[$j]->type == "date") {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d", strtotime($row[$j])) . '" table:style-name="DateCell">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
             } elseif ($fields_meta[$j]->type == "time") {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="time" office:time-value="' . date("\\P\\TH\\Hi\\Ms\\S", strtotime($row[$j])) . '" table:style-name="TimeCell">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
             } elseif ($fields_meta[$j]->type == "datetime") {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d\\TH:i:s", strtotime($row[$j])) . '" table:style-name="DateTimeCell">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
             } elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
             } else {
                 $GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
             }
         }
         // end for
         $GLOBALS['ods_buffer'] .= '</table:table-row>';
     }
     // end while
     PMA_DBI_free_result($result);
     $GLOBALS['ods_buffer'] .= '</table:table>';
     return true;
 }
Example #13
0
 /**
  * Outputs the content of a table in CSV format
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $what;
     if (!PMA_exportOutputHandler('== ' . $GLOBALS['strDumpingData'] . ' ' . $table . "\n\n")) {
         return FALSE;
     }
     // Gets the data from the database
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $fields_cnt = PMA_DBI_num_fields($result);
     // If required, get fields name at the first line
     if (isset($GLOBALS[$what . '_columns'])) {
         $text_output = "|------\n";
         for ($i = 0; $i < $fields_cnt; $i++) {
             $text_output .= '|' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i)));
         }
         // end for
         $text_output .= "\n|------\n";
         if (!PMA_exportOutputHandler($text_output)) {
             return FALSE;
         }
     }
     // end if
     // Format the data
     while ($row = PMA_DBI_fetch_row($result)) {
         $text_output = '';
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j]) || is_null($row[$j])) {
                 $value = $GLOBALS[$what . '_null'];
             } elseif ($row[$j] == '0' || $row[$j] != '') {
                 $value = $row[$j];
             } else {
                 $value = ' ';
             }
             $text_output .= '|' . htmlspecialchars($value);
         }
         // end for
         $text_output .= "\n";
         if (!PMA_exportOutputHandler($text_output)) {
             return FALSE;
         }
     }
     // end while
     PMA_DBI_free_result($result);
     return TRUE;
 }
Example #14
0
 /**
  * Outputs the content of a table in YAML format
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $columns_cnt = PMA_DBI_num_fields($result);
     for ($i = 0; $i < $columns_cnt; $i++) {
         $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
     }
     unset($i);
     $cnt = 0;
     $buffer = '';
     while ($record = PMA_DBI_fetch_row($result)) {
         $cnt++;
         $buffer = $cnt . ":{$crlf}";
         for ($i = 0; $i < $columns_cnt; $i++) {
             if (isset($record[$i]) && !is_null($record[$i])) {
                 $buffer .= '  ' . $columns[$i] . ': ' . htmlspecialchars($record[$i]) . $crlf;
             }
         }
         if (!PMA_exportOutputHandler($buffer)) {
             return FALSE;
         }
     }
     PMA_DBI_free_result($result);
     return TRUE;
 }
Example #15
0
 /**
  * Outputs the content of a table in CSV format
  *
  * @param string  $db         database name
  * @param string  $table      table name
  * @param string  $crlf       the end of line sequence
  * @param string  $error_url  the url to go back in case of error
  * @param string  $sql_query  SQL query for obtaining data
  * @return  bool        Whether it succeeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $what;
     global $csv_terminated;
     global $csv_separator;
     global $csv_enclosed;
     global $csv_escaped;
     // Gets the data from the database
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $fields_cnt = PMA_DBI_num_fields($result);
     // If required, get fields name at the first line
     if (isset($GLOBALS['csv_columns'])) {
         $schema_insert = '';
         for ($i = 0; $i < $fields_cnt; $i++) {
             if ($csv_enclosed == '') {
                 $schema_insert .= stripslashes(PMA_DBI_field_name($result, $i));
             } else {
                 $schema_insert .= $csv_enclosed . str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, stripslashes(PMA_DBI_field_name($result, $i))) . $csv_enclosed;
             }
             $schema_insert .= $csv_separator;
         }
         // end for
         $schema_insert = trim(substr($schema_insert, 0, -1));
         if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
             return false;
         }
     }
     // end if
     // Format the data
     while ($row = PMA_DBI_fetch_row($result)) {
         $schema_insert = '';
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j]) || is_null($row[$j])) {
                 $schema_insert .= $GLOBALS[$what . '_null'];
             } elseif ($row[$j] == '0' || $row[$j] != '') {
                 // always enclose fields
                 if ($what == 'excel') {
                     $row[$j] = preg_replace("/\r(\n)?/", "\n", $row[$j]);
                 }
                 // remove CRLF characters within field
                 if (isset($GLOBALS[$what . '_removeCRLF']) && $GLOBALS[$what . '_removeCRLF']) {
                     $row[$j] = str_replace("\n", "", str_replace("\r", "", $row[$j]));
                 }
                 if ($csv_enclosed == '') {
                     $schema_insert .= $row[$j];
                 } else {
                     // also double the escape string if found in the data
                     if ($csv_escaped != $csv_enclosed) {
                         $schema_insert .= $csv_enclosed . str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, str_replace($csv_escaped, $csv_escaped . $csv_escaped, $row[$j])) . $csv_enclosed;
                     } else {
                         // avoid a problem when escape string equals enclose
                         $schema_insert .= $csv_enclosed . str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, $row[$j]) . $csv_enclosed;
                     }
                 }
             } else {
                 $schema_insert .= '';
             }
             if ($j < $fields_cnt - 1) {
                 $schema_insert .= $csv_separator;
             }
         }
         // end for
         if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
             return false;
         }
     }
     // end while
     PMA_DBI_free_result($result);
     return true;
 }
Example #16
0
 /**
  * Outputs the content of a table
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $what;
     if (isset($GLOBALS[$what . '_export_contents']) && $GLOBALS[$what . '_export_contents']) {
         $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
         $columns_cnt = PMA_DBI_num_fields($result);
         for ($i = 0; $i < $columns_cnt; $i++) {
             $columns[$i] = stripslashes(str_replace(' ', '_', PMA_DBI_field_name($result, $i)));
         }
         unset($i);
         $buffer = '        <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
         if (!PMA_exportOutputHandler($buffer)) {
             return FALSE;
         }
         while ($record = PMA_DBI_fetch_row($result)) {
             $buffer = '        <table name="' . htmlspecialchars($table) . '">' . $crlf;
             for ($i = 0; $i < $columns_cnt; $i++) {
                 // If a cell is NULL, still export it to preserve the XML structure
                 if (!isset($record[$i]) || is_null($record[$i])) {
                     $record[$i] = 'NULL';
                 }
                 $buffer .= '            <column name="' . $columns[$i] . '">' . htmlspecialchars(utf8_encode((string) $record[$i])) . '</column>' . $crlf;
             }
             $buffer .= '        </table>' . $crlf;
             if (!PMA_exportOutputHandler($buffer)) {
                 return FALSE;
             }
         }
         PMA_DBI_free_result($result);
     }
     return TRUE;
 }
 /**
  * Outputs the content of a table in YAML format
  *
  * @param string  $db         database name
  * @param string  $table      table name
  * @param string  $crlf       the end of line sequence
  * @param string  $error_url  the url to go back in case of error
  * @param string  $sql_query  SQL query for obtaining data
  * @return  bool        Whether it succeeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $columns_cnt = PMA_DBI_num_fields($result);
     for ($i = 0; $i < $columns_cnt; $i++) {
         $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
     }
     unset($i);
     $buffer = '';
     $record_cnt = 0;
     while ($record = PMA_DBI_fetch_row($result)) {
         $record_cnt++;
         // Output table name as comment if this is the first record of the table
         if ($record_cnt == 1) {
             $buffer = '# ' . $db . '.' . $table . $crlf;
             $buffer .= '-' . $crlf;
         } else {
             $buffer = '-' . $crlf;
         }
         for ($i = 0; $i < $columns_cnt; $i++) {
             if (!isset($record[$i])) {
                 continue;
             }
             $column = $columns[$i];
             if (is_null($record[$i])) {
                 $buffer .= '  ' . $column . ': null' . $crlf;
                 continue;
             }
             if (is_numeric($record[$i])) {
                 $buffer .= '  ' . $column . ': ' . $record[$i] . $crlf;
                 continue;
             }
             $record[$i] = str_replace(array('\\', '"', "\n", "\r"), array('\\\\', '\\"', '\\n', '\\r'), $record[$i]);
             $buffer .= '  ' . $column . ': "' . $record[$i] . '"' . $crlf;
         }
         if (!PMA_exportOutputHandler($buffer)) {
             return false;
         }
     }
     PMA_DBI_free_result($result);
     return true;
 }
Example #18
0
 /**
  * Outputs the content of a table in CSV format
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $what;
     // Gets the data from the database
     $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $fields_cnt = PMA_DBI_num_fields($result);
     $fields_meta = PMA_DBI_get_fields_meta($result);
     $field_flags = array();
     for ($j = 0; $j < $fields_cnt; $j++) {
         $field_flags[$j] = PMA_DBI_field_flags($result, $j);
     }
     $GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . htmlspecialchars(__('Dumping data for table') . ' ' . $table) . '</text:h>';
     $GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '_structure">';
     $GLOBALS['odt_buffer'] .= '<table:table-column table:number-columns-repeated="' . $fields_cnt . '"/>';
     // If required, get fields name at the first line
     if (isset($GLOBALS[$what . '_columns'])) {
         $GLOBALS['odt_buffer'] .= '<table:table-row>';
         for ($i = 0; $i < $fields_cnt; $i++) {
             $GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>' . '</table:table-cell>';
         }
         // end for
         $GLOBALS['odt_buffer'] .= '</table:table-row>';
     }
     // end if
     // Format the data
     while ($row = PMA_DBI_fetch_row($result)) {
         $GLOBALS['odt_buffer'] .= '<table:table-row>';
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j]) || is_null($row[$j])) {
                 $GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>' . '</table:table-cell>';
                 // ignore BLOB
             } elseif (stristr($field_flags[$j], 'BINARY') && $fields_meta[$j]->blob) {
                 $GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p></text:p>' . '</table:table-cell>';
             } elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) {
                 $GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
             } else {
                 $GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
             }
         }
         // end for
         $GLOBALS['odt_buffer'] .= '</table:table-row>';
     }
     // end while
     PMA_DBI_free_result($result);
     $GLOBALS['odt_buffer'] .= '</table:table>';
     return TRUE;
 }
Example #19
0
 /**
  * Outputs the content of a table in LaTeX table/sideways table environment
  *
  * @param   string      the database name
  * @param   string      the table name
  * @param   string      the end of line sequence
  * @param   string      the url to go back in case of error
  * @param   string      SQL query for obtaining data
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     $result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $columns_cnt = PMA_DBI_num_fields($result);
     for ($i = 0; $i < $columns_cnt; $i++) {
         $columns[$i] = PMA_DBI_field_name($result, $i);
     }
     unset($i);
     $buffer = $crlf . '%' . $crlf . '% ' . $GLOBALS['strData'] . ': ' . $table . $crlf . '%' . $crlf . ' \\begin{longtable}{|';
     for ($index = 0; $index < $columns_cnt; $index++) {
         $buffer .= 'l|';
     }
     $buffer .= '} ' . $crlf;
     $buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . $crlf;
     if (isset($GLOBALS['latex_caption'])) {
         $buffer .= ' \\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_caption']) . '} \\label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_data_label']) . '} \\\\';
     }
     if (!PMA_exportOutputHandler($buffer)) {
         return FALSE;
     }
     // show column names
     if (isset($GLOBALS['latex_columns'])) {
         $buffer = '\\hline ';
         for ($i = 0; $i < $columns_cnt; $i++) {
             $buffer .= '\\multicolumn{1}{|c|}{\\textbf{' . PMA_texEscape(stripslashes($columns[$i])) . '}} & ';
         }
         $buffer = substr($buffer, 0, -2) . '\\\\ \\hline \\hline ';
         if (!PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
             return FALSE;
         }
         if (isset($GLOBALS['latex_caption'])) {
             if (!PMA_exportOutputHandler('\\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_continued_caption']) . '} \\\\ ')) {
                 return FALSE;
             }
         }
         if (!PMA_exportOutputHandler($buffer . '\\endhead \\endfoot' . $crlf)) {
             return FALSE;
         }
     } else {
         if (!PMA_exportOutputHandler('\\\\ \\hline')) {
             return FALSE;
         }
     }
     // print the whole table
     while ($record = PMA_DBI_fetch_assoc($result)) {
         $buffer = '';
         // print each row
         for ($i = 0; $i < $columns_cnt; $i++) {
             if (isset($record[$columns[$i]]) && (!function_exists('is_null') || !is_null($record[$columns[$i]]))) {
                 $column_value = PMA_texEscape(stripslashes($record[$columns[$i]]));
             } else {
                 $column_value = $GLOBALS['latex_null'];
             }
             // last column ... no need for & character
             if ($i == $columns_cnt - 1) {
                 $buffer .= $column_value;
             } else {
                 $buffer .= $column_value . " & ";
             }
         }
         $buffer .= ' \\\\ \\hline ' . $crlf;
         if (!PMA_exportOutputHandler($buffer)) {
             return FALSE;
         }
     }
     $buffer = ' \\end{longtable}' . $crlf;
     if (!PMA_exportOutputHandler($buffer)) {
         return FALSE;
     }
     PMA_DBI_free_result($result);
     return TRUE;
 }
 /**
  * Outputs the content of a table in JSON format
  *
  * @param string $db        database name
  * @param string $table     table name
  * @param string $crlf      the end of line sequence
  * @param string $error_url the url to go back in case of error
  * @param string $sql_query SQL query for obtaining data
  *
  * @return bool Whether it succeeded
  */
 public function exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     $common_functions = PMA_CommonFunctions::getInstance();
     $result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     $columns_cnt = PMA_DBI_num_fields($result);
     for ($i = 0; $i < $columns_cnt; $i++) {
         $columns[$i] = PMA_DBI_field_name($result, $i);
     }
     unset($i);
     $buffer = $crlf . '%' . $crlf . '% ' . __('Data') . ': ' . $table . $crlf . '%' . $crlf . ' \\begin{longtable}{|';
     for ($index = 0; $index < $columns_cnt; $index++) {
         $buffer .= 'l|';
     }
     $buffer .= '} ' . $crlf;
     $buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . $crlf;
     if (isset($GLOBALS['latex_caption'])) {
         $buffer .= ' \\caption{' . $common_functions->expandUserString($GLOBALS['latex_data_caption'], 'texEscape', get_class($this), array('table' => $table, 'database' => $db)) . '} \\label{' . $common_functions->expandUserString($GLOBALS['latex_data_label'], null, null, array('table' => $table, 'database' => $db)) . '} \\\\';
     }
     if (!PMA_exportOutputHandler($buffer)) {
         return false;
     }
     // show column names
     if (isset($GLOBALS['latex_columns'])) {
         $buffer = '\\hline ';
         for ($i = 0; $i < $columns_cnt; $i++) {
             $buffer .= '\\multicolumn{1}{|c|}{\\textbf{' . $this::texEscape(stripslashes($columns[$i])) . '}} & ';
         }
         $buffer = substr($buffer, 0, -2) . '\\\\ \\hline \\hline ';
         if (!PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
             return false;
         }
         if (isset($GLOBALS['latex_caption'])) {
             if (!PMA_exportOutputHandler('\\caption{' . $common_functions->expandUserString($GLOBALS['latex_data_continued_caption'], 'texEscape', get_class($this), array('table' => $table, 'database' => $db)) . '} \\\\ ')) {
                 return false;
             }
         }
         if (!PMA_exportOutputHandler($buffer . '\\endhead \\endfoot' . $crlf)) {
             return false;
         }
     } else {
         if (!PMA_exportOutputHandler('\\\\ \\hline')) {
             return false;
         }
     }
     // print the whole table
     while ($record = PMA_DBI_fetch_assoc($result)) {
         $buffer = '';
         // print each row
         for ($i = 0; $i < $columns_cnt; $i++) {
             if ((!function_exists('is_null') || !is_null($record[$columns[$i]])) && isset($record[$columns[$i]])) {
                 $column_value = $this::texEscape(stripslashes($record[$columns[$i]]));
             } else {
                 $column_value = $GLOBALS['latex_null'];
             }
             // last column ... no need for & character
             if ($i == $columns_cnt - 1) {
                 $buffer .= $column_value;
             } else {
                 $buffer .= $column_value . " & ";
             }
         }
         $buffer .= ' \\\\ \\hline ' . $crlf;
         if (!PMA_exportOutputHandler($buffer)) {
             return false;
         }
     }
     $buffer = ' \\end{longtable}' . $crlf;
     if (!PMA_exportOutputHandler($buffer)) {
         return false;
     }
     PMA_DBI_free_result($result);
     return true;
 }