home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / db_routines.inc.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  4.3 KB  |  92 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: db_routines.inc.php 11326 2008-06-17 21:32:48Z lem9 $
  6.  */
  7. if (! defined('PHPMYADMIN')) {
  8.     exit;
  9. }
  10.  
  11. /**
  12.  * @todo Support seeing the "results" of the called procedure or
  13.  *       function. This needs further reseach because a procedure
  14.  *       does not necessarily contain a SELECT statement that
  15.  *       produces something to see. But it seems we could at least
  16.  *       get the number of rows affected. We would have to
  17.  *       use the CLIENT_MULTI_RESULTS flag to get the result set
  18.  *       and also the call status. All this does not fit well with
  19.  *       our current sql.php.
  20.  *       Of course the interface would need a way to pass calling parameters.
  21.  *       Also, support DEFINER (like we do in export).
  22.  */
  23. if (PMA_MYSQL_INT_VERSION >= 50002) {
  24.     $url_query .= '&goto=db_structure.php';
  25.  
  26.     $routines = PMA_DBI_fetch_result('SELECT SPECIFIC_NAME,ROUTINE_NAME,ROUTINE_TYPE,DTD_IDENTIFIER FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA= \'' . PMA_sqlAddslashes($db,true) . '\';');
  27.  
  28.     if ($routines) {
  29.         echo '<fieldset>' . "\n";
  30.         echo ' <legend>' . $strRoutines . '</legend>' . "\n";
  31.         echo '<table border="0">';
  32.         echo sprintf('<tr>
  33.                           <th>%s</th>
  34.                           <th> </th>
  35.                           <th> </th>
  36.                           <th>%s</th>
  37.                           <th>%s</th>
  38.                     </tr>',
  39.               $strName,
  40.               $strType,
  41.               $strRoutineReturnType);
  42.         $ct=0;
  43.         $delimiter = '//';
  44.         foreach ($routines as $routine) {
  45.  
  46.             // information_schema (at least in MySQL 5.0.45)
  47.             // does not return the routine parameters
  48.             // so we rely on PMA_DBI_get_procedure_or_function_def() which
  49.             // uses SHOW CREATE
  50.  
  51.             $definition = 'DROP ' . $routine['ROUTINE_TYPE'] . ' ' . PMA_backquote($routine['SPECIFIC_NAME']) . $delimiter . "\n"
  52.                 .  PMA_DBI_get_procedure_or_function_def($db, $routine['ROUTINE_TYPE'], $routine['SPECIFIC_NAME'])
  53.                 . "\n";
  54.  
  55.             //if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
  56.             //    $sqlUseProc  = 'CALL ' . $routine['SPECIFIC_NAME'] . '()';
  57.             //} else {
  58.             //    $sqlUseProc = 'SELECT ' . $routine['SPECIFIC_NAME'] . '()';
  59.                 /* this won't get us far: to really use the function
  60.                    i'd need to know how many parameters the function needs and then create
  61.                    something to ask for them. As i don't see this directly in
  62.                    the table i am afraid that requires parsing the ROUTINE_DEFINITION
  63.                    and i don't really need that now so i simply don't offer
  64.                    a method for running the function*/
  65.             //}
  66.             if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
  67.                 $sqlDropProc = 'DROP PROCEDURE ' . PMA_backquote($routine['SPECIFIC_NAME']);
  68.             } else {
  69.                 $sqlDropProc = 'DROP FUNCTION ' . PMA_backquote($routine['SPECIFIC_NAME']);
  70.             }
  71.             echo sprintf('<tr class="%s">
  72.                               <td><b>%s</b></td>
  73.                               <td>%s</td>
  74.                               <td>%s</td>
  75.                               <td>%s</td>
  76.                               <td>%s</td>
  77.                          </tr>',
  78.                          ($ct%2 == 0) ? 'even' : 'odd',
  79.                          $routine['ROUTINE_NAME'],
  80.                          ! empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&sql_query=' . urlencode($definition) . '&show_query=1&delimiter=' . urlencode($delimiter), $titles['Structure']) : ' ',
  81.                          //$routine['ROUTINE_TYPE'] == 'PROCEDURE' ? '<a href="sql.php?' . $url_query . '&sql_query=' . urlencode($sqlUseProc) . '">' . $titles['Browse'] . '</a>' : ' ',
  82.                          '<a href="sql.php?' . $url_query . '&sql_query=' . urlencode($sqlDropProc) . '" onclick="return confirmLink(this, \'' . PMA_jsFormat($sqlDropProc, false) . '\')">' . $titles['Drop'] . '</a>',
  83.                          $routine['ROUTINE_TYPE'],
  84.                          $routine['DTD_IDENTIFIER']);
  85.             $ct++;
  86.         }
  87.         echo '</table>';
  88.         echo '</fieldset>' . "\n";
  89.     }
  90. }
  91. ?>
  92.