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