home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / view_create.php < prev   
PHP Script  |  2008-06-23  |  4KB  |  148 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: view_create.php 10606 2007-09-05 10:17:18Z lem9 $
  6.  */
  7.  
  8. /**
  9.  *
  10.  */
  11. require_once './libraries/common.inc.php';
  12.  
  13. /**
  14.  * Runs common work
  15.  */
  16. require './libraries/db_common.inc.php';
  17. $url_params['goto'] = $url_params['back'] = 'view_create.php';
  18.  
  19. if (isset($_POST['submitoptions'])) {
  20.     /**
  21.      * Creates the view
  22.      */
  23.     $message = '';
  24.     $sep = "\r\n";
  25.     $create_query = 'CREATE' . $sep;
  26.     if (isset($_POST['or_replace'])) {
  27.         $create_query .= ' OR REPLACE' . $sep;
  28.     }
  29.     if (isset($_POST['algorithm'])) {
  30.         $create_query .= ' ALGORITHM = ' . $_POST['algorithm'] . $sep;
  31.     }
  32.     $create_query .= ' VIEW ' . $_POST['view_name'] . $sep;
  33.  
  34.     if (!empty($_POST['column_names'])) {
  35.         $create_query .= ' (' . $_POST['column_names'] . ')' . $sep;
  36.     }
  37.  
  38.     $create_query .= ' AS ' . $_POST['sql_statement'] . $sep;
  39.  
  40.     if (isset($_POST['cascaded']) || isset($_POST['local']) || isset($_POST['check_option'])) {
  41.         $create_query .= ' WITH ';
  42.     }
  43.  
  44.     if (isset($_POST['cascaded'])) {
  45.         $create_query .= ' CASCADED ';
  46.     }
  47.  
  48.     if (isset($_POST['local'])) {
  49.         $create_query .= ' LOCAL ';
  50.     }
  51.  
  52.     if (isset($_POST['check_option'])) {
  53.         $create_query .= ' CHECK OPTION ';
  54.     }
  55.  
  56.     $message        .= PMA_DBI_query($create_query) ? $strSuccess : $strError;
  57.  
  58.     // to display the CREATE VIEW query
  59.     $sql_query = $create_query;
  60.  
  61.     require './' .  $cfg['DefaultTabDatabase'];
  62.     exit();
  63.  
  64. } else {
  65.     /**
  66.      * Displays top menu links
  67.      * We use db links because a VIEW is not necessarily on a single table
  68.      */
  69.     $num_tables = 0;
  70.     require_once './libraries/db_links.inc.php';
  71.  
  72.     $url_params['goto'] = 'view_create.php';
  73.     $url_params['back'] = 'view_create.php';
  74.  
  75.     /**
  76.      * Displays the page
  77.      *
  78.      * @todo js error when view name is empty (strFormEmpty)
  79.      * @todo (also validate if js is disabled, after form submission?)
  80.      */
  81.  
  82. ?>
  83. <!-- CREATE VIEW options -->
  84. <div id="div_view_options">
  85. <form method="post" action="view_create.php">
  86. <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db']); ?>
  87. <input type="hidden" name="reload" value="1" />
  88. <fieldset>
  89.     <legend>CREATE VIEW</legend>
  90.  
  91.     <table>
  92.     <tr><td><label for="or_replace">OR REPLACE</label></td>
  93.         <td><input type="checkbox" name="or_replace" id="or_replace"
  94.                 value="1" />
  95.         </td>
  96.     </tr>
  97.     <tr>
  98.         <td><label for="algorithm">ALGORITHM</label></td>
  99.         <td><select name="algorithm" id="algorithm">
  100.                 <option value="UNDEFINED">UNDEFINED</option>
  101.                 <option value="MERGE">MERGE</option>
  102.                 <option value="TEMPTABLE">TEMPTABLE</option>
  103.             </select>
  104.         </td>
  105.     </tr>
  106.     <tr><td><?php echo $strViewName; ?></td>
  107.         <td><input type="text" size="20" name="view_name" onfocus="this.select()"
  108.                 value="" />
  109.         </td>
  110.     </tr>
  111.  
  112.     <tr><td><?php echo $strColumnNames; ?></td>
  113.         <td><input type="text" maxlength="100" size="50" name="column_names" onfocus="this.select()"
  114.                 value="" />
  115.         </td>
  116.     </tr>
  117.  
  118.     <tr><td><?php echo 'AS' ?></td>
  119.         <td>
  120.             <textarea name="sql_statement" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" dir="<?php echo $text_dir; ?>" onfocus="this.select();"><?php echo htmlspecialchars($sql_query); ?></textarea> 
  121.         </td>
  122.     </tr>
  123.     <tr><td>WITH</td>
  124.         <td>
  125.             <input type="checkbox" name="cascaded" id="cascaded" value="1" />
  126.             <label for="cascaded">CASCADED</label>
  127.             <input type="checkbox" name="local" id="local" value="1" />
  128.             <label for="local">LOCAL</label>
  129.             <input type="checkbox" name="check_option" id="check_option" value="1" />
  130.             <label for="check_option">CHECK OPTION</label>
  131.         </td>
  132.     </tr>
  133.     </table>
  134. </fieldset>
  135. <fieldset class="tblFooters">
  136.         <input type="submit" name="submitoptions" value="<?php echo $strGo; ?>" />
  137. </fieldset>
  138. </form>
  139. </div>
  140. <?php
  141. /**
  142.  * Displays the footer
  143.  */
  144. require_once './libraries/footer.inc.php';
  145.  
  146. } // end if
  147. ?>
  148.