Translation update done using Pootle.
[phpmyadmin/ammar_yasir.git] / libraries / db_routines.inc.php
blob49819dd1ac42ba02b4b388046ff2a191a94bb539
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 * @package phpMyAdmin
17 if (! defined('PHPMYADMIN')) {
18 exit;
21 $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) . '\';');
23 if ($routines) {
24 PMA_generate_slider_effect('routines', __('Routines'));
25 echo '<fieldset>' . "\n";
26 echo ' <legend>' . __('Routines') . '</legend>' . "\n";
27 echo '<table border="0">';
28 echo sprintf('<tr>
29 <th>%s</th>
30 <th>&nbsp;</th>
31 <th>&nbsp;</th>
32 <th>%s</th>
33 <th>%s</th>
34 </tr>',
35 __('Name'),
36 __('Type'),
37 __('Return type'));
38 $ct=0;
39 $delimiter = '//';
40 foreach ($routines as $routine) {
42 // information_schema (at least in MySQL 5.0.45)
43 // does not return the routine parameters
44 // so we rely on PMA_DBI_get_definition() which
45 // uses SHOW CREATE
47 $definition = 'DROP ' . $routine['ROUTINE_TYPE'] . ' ' . PMA_backquote($routine['SPECIFIC_NAME']) . $delimiter . "\n"
48 . PMA_DBI_get_definition($db, $routine['ROUTINE_TYPE'], $routine['SPECIFIC_NAME'])
49 . "\n";
51 //if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
52 // $sqlUseProc = 'CALL ' . $routine['SPECIFIC_NAME'] . '()';
53 //} else {
54 // $sqlUseProc = 'SELECT ' . $routine['SPECIFIC_NAME'] . '()';
55 /* this won't get us far: to really use the function
56 i'd need to know how many parameters the function needs and then create
57 something to ask for them. As i don't see this directly in
58 the table i am afraid that requires parsing the ROUTINE_DEFINITION
59 and i don't really need that now so i simply don't offer
60 a method for running the function*/
61 //}
62 if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
63 $sqlDropProc = 'DROP PROCEDURE ' . PMA_backquote($routine['SPECIFIC_NAME']);
64 } else {
65 $sqlDropProc = 'DROP FUNCTION ' . PMA_backquote($routine['SPECIFIC_NAME']);
67 echo sprintf('<tr class="%s">
68 <td><strong>%s</strong></td>
69 <td>%s</td>
70 <td>%s</td>
71 <td>%s</td>
72 <td>%s</td>
73 <input type="hidden" class="drop_procedure_sql" value="%s" />
74 </tr>',
75 ($ct%2 == 0) ? 'even' : 'odd',
76 $routine['ROUTINE_NAME'],
77 ! empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($definition) . '&amp;show_query=1&amp;db_query_force=1&amp;delimiter=' . urlencode($delimiter), $titles['Structure']) : '&nbsp;',
78 '<a class="drop_procedure_anchor" href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sqlDropProc) . '" >' . $titles['Drop'] . '</a>',
79 $routine['ROUTINE_TYPE'],
80 $routine['DTD_IDENTIFIER'],
81 $sqlDropProc);
82 $ct++;
84 echo '</table>';
85 echo '</fieldset>' . "\n";
86 echo '</div>' . "\n";