unQuote() public static method

checks if the string is quoted and removes this quotes
public static unQuote ( string $quoted_string, string $quote = null ) : string
$quoted_string string string to remove quotes from
$quote string type of quote to remove
return string unqoted string
 /**
  * Prepare sorted column message
  *
  * @param integer &$dt_result                  the link id associated to the
  *                                              query which results have to
  *                                              be displayed
  * @param string  $sort_expression_nodirection sort expression without direction
  *
  * @return  string                              html content
  *          null                                if not found sorted column
  *
  * @access  private
  *
  * @see     getTable()
  */
 private function _getSortedColumnMessage(&$dt_result, $sort_expression_nodirection)
 {
     $fields_meta = $this->__get('fields_meta');
     // To use array indexes
     if (empty($sort_expression_nodirection)) {
         return null;
     }
     if (mb_strpos($sort_expression_nodirection, '.') === false) {
         $sort_table = $this->__get('table');
         $sort_column = $sort_expression_nodirection;
     } else {
         list($sort_table, $sort_column) = explode('.', $sort_expression_nodirection);
     }
     $sort_table = Util::unQuote($sort_table);
     $sort_column = Util::unQuote($sort_column);
     // find the sorted column index in row result
     // (this might be a multi-table query)
     $sorted_column_index = false;
     foreach ($fields_meta as $key => $meta) {
         if ($meta->table == $sort_table && $meta->name == $sort_column) {
             $sorted_column_index = $key;
             break;
         }
     }
     if ($sorted_column_index === false) {
         return null;
     }
     // fetch first row of the result set
     $row = $GLOBALS['dbi']->fetchRow($dt_result);
     // initializing default arguments
     $default_function = 'PMA_mimeDefaultFunction';
     $transformation_plugin = $default_function;
     $transform_options = array();
     // check for non printable sorted row data
     $meta = $fields_meta[$sorted_column_index];
     if (stristr($meta->type, self::BLOB_FIELD) || $meta->type == self::GEOMETRY_FIELD) {
         $column_for_first_row = $this->_handleNonPrintableContents($meta->type, $row[$sorted_column_index], $transformation_plugin, $transform_options, $default_function, $meta);
     } else {
         $column_for_first_row = $row[$sorted_column_index];
     }
     $column_for_first_row = mb_strtoupper(mb_substr($column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']) . '...');
     // fetch last row of the result set
     $GLOBALS['dbi']->dataSeek($dt_result, $this->__get('num_rows') - 1);
     $row = $GLOBALS['dbi']->fetchRow($dt_result);
     // check for non printable sorted row data
     $meta = $fields_meta[$sorted_column_index];
     if (stristr($meta->type, self::BLOB_FIELD) || $meta->type == self::GEOMETRY_FIELD) {
         $column_for_last_row = $this->_handleNonPrintableContents($meta->type, $row[$sorted_column_index], $transformation_plugin, $transform_options, $default_function, $meta);
     } else {
         $column_for_last_row = $row[$sorted_column_index];
     }
     $column_for_last_row = mb_strtoupper(mb_substr($column_for_last_row, 0, $GLOBALS['cfg']['LimitChars']) . '...');
     // reset to first row for the loop in _getTableBody()
     $GLOBALS['dbi']->dataSeek($dt_result, 0);
     // we could also use here $sort_expression_nodirection
     return ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]';
 }
Beispiel #2
0
/**
 * Checks if a table is 'InnoDB' or not.
 *
 * @param string $table Table details
 *
 * @return bool
 */
function PMA_isTableTransactional($table)
{
    $table = explode('.', $table);
    if (count($table) == 2) {
        $db = PMA\libraries\Util::unQuote($table[0]);
        $table = PMA\libraries\Util::unQuote($table[1]);
    } else {
        $db = $GLOBALS['db'];
        $table = PMA\libraries\Util::unQuote($table[0]);
    }
    // Query to check if table exists.
    $check_table_query = 'SELECT * FROM ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($table) . ' ' . 'LIMIT 1';
    $result = $GLOBALS['dbi']->tryQuery($check_table_query);
    if (!$result) {
        return false;
    }
    // List of Transactional Engines.
    $transactional_engines = array('INNODB', 'FALCON', 'NDB', 'INFINIDB', 'TOKUDB', 'XTRADB', 'SEQUENCE', 'BDB');
    // Query to check if table is 'Transactional'.
    $check_query = 'SELECT `ENGINE` FROM `information_schema`.`tables` ' . 'WHERE `table_name` = "' . $table . '" ' . 'AND `table_schema` = "' . $db . '" ' . 'AND UPPER(`engine`) IN ("' . implode('", "', $transactional_engines) . '")';
    $result = $GLOBALS['dbi']->tryQuery($check_query);
    if ($GLOBALS['dbi']->numRows($result) == 1) {
        return true;
    } else {
        return false;
    }
}