original_string: function create_table_php($structure, $table) {
  
          $result = '';
          // Validate if we can do it
          if (!$table = $structure->getTable($table)) {
              return false;
          }
          if ($table->getAllErrors()) {
              return false;
          }
  
          // Add the standard PHP header
          $result .= XMLDB_PHP_HEADER;
  
          // Add contents
          $result .= XMLDB_LINEFEED;
          $result .= '        // Define table ' . $table->getName() . ' to be created.' . XMLDB_LINEFEED;
          $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
          $result .= XMLDB_LINEFEED;
          $result .= '        // Adding fields to table ' . $table->getName() . '.' . XMLDB_LINEFEED;
          // Iterate over each field
          foreach ($table->getFields() as $field) {
              // The field header, with name
              $result .= '        $table->add_field(' . "'" . $field->getName() . "', ";
              // The field PHP specs
              $result .= $field->getPHP(false);
              // The end of the line
              $result .= ');' . XMLDB_LINEFEED;
          }
          // Iterate over each key
          if ($keys = $table->getKeys()) {
              $result .= XMLDB_LINEFEED;
              $result .= '        // Adding keys to table ' . $table->getName() . '.' . XMLDB_LINEFEED;
              foreach ($keys as $key) {
                  // The key header, with name
                  $result .= '        $table->add_key(' . "'" . $key->getName() . "', ";
                  // The key PHP specs
                  $result .= $key->getPHP();
                  // The end of the line
                  $result .= ');' . XMLDB_LINEFEED;
              }
          }
          // Iterate over each index
          if ($indexes = $table->getIndexes()) {
              $result .= XMLDB_LINEFEED;
              $result .= '        // Adding indexes to table ' . $table->getName() . '.' . XMLDB_LINEFEED;
              foreach ($indexes as $index) {
                  // The index header, with name
                  $result .= '        $table->add_index(' . "'" . $index->getName() . "', ";
                  // The index PHP specs
                  $result .= $index->getPHP();
                  // The end of the line
                  $result .= ');' . XMLDB_LINEFEED;
              }
          }
  
          // Launch the proper DDL
          $result .= XMLDB_LINEFEED;
          $result .= '        // Conditionally launch create table for ' . $table->getName() . '.' . XMLDB_LINEFEED;
          $result .= '        if (!$dbman->table_exists($table)) {' . XMLDB_LINEFEED;
          $result .= '            $dbman->create_table($table);' . XMLDB_LINEFEED;
          $result .= '        }' . XMLDB_LINEFEED;
  
          // Add the proper upgrade_xxxx_savepoint call
          $result .= $this->upgrade_savepoint_php ($structure);
  
          // Add standard PHP footer
          $result .= XMLDB_PHP_FOOTER;
  
          return $result;
      }
code: function create_table_php($structure, $table) {
  
          $result = '';
          // Validate if we can do it
          if (!$table = $structure->getTable($table)) {
              return false;
          }
          if ($table->getAllErrors()) {
              return false;
          }
  
          // Add the standard PHP header
          $result .= XMLDB_PHP_HEADER;
  
          // Add contents
          $result .= XMLDB_LINEFEED;
          $result .= '        // Define table ' . $table->getName() . ' to be created.' . XMLDB_LINEFEED;
          $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
          $result .= XMLDB_LINEFEED;
          $result .= '        // Adding fields to table ' . $table->getName() . '.' . XMLDB_LINEFEED;
          // Iterate over each field
          foreach ($table->getFields() as $field) {
              // The field header, with name
              $result .= '        $table->add_field(' . "'" . $field->getName() . "', ";
              // The field PHP specs
              $result .= $field->getPHP(false);
              // The end of the line
              $result .= ');' . XMLDB_LINEFEED;
          }
          // Iterate over each key
          if ($keys = $table->getKeys()) {
              $result .= XMLDB_LINEFEED;
              $result .= '        // Adding keys to table ' . $table->getName() . '.' . XMLDB_LINEFEED;
              foreach ($keys as $key) {
                  // The key header, with name
                  $result .= '        $table->add_key(' . "'" . $key->getName() . "', ";
                  // The key PHP specs
                  $result .= $key->getPHP();
                  // The end of the line
                  $result .= ');' . XMLDB_LINEFEED;
              }
          }
          // Iterate over each index
          if ($indexes = $table->getIndexes()) {
              $result .= XMLDB_LINEFEED;
              $result .= '        // Adding indexes to table ' . $table->getName() . '.' . XMLDB_LINEFEED;
              foreach ($indexes as $index) {
                  // The index header, with name
                  $result .= '        $table->add_index(' . "'" . $index->getName() . "', ";
                  // The index PHP specs
                  $result .= $index->getPHP();
                  // The end of the line
                  $result .= ');' . XMLDB_LINEFEED;
              }
          }
  
          // Launch the proper DDL
          $result .= XMLDB_LINEFEED;
          $result .= '        // Conditionally launch create table for ' . $table->getName() . '.' . XMLDB_LINEFEED;
          $result .= '        if (!$dbman->table_exists($table)) {' . XMLDB_LINEFEED;
          $result .= '            $dbman->create_table($table);' . XMLDB_LINEFEED;
          $result .= '        }' . XMLDB_LINEFEED;
  
          // Add the proper upgrade_xxxx_savepoint call
          $result .= $this->upgrade_savepoint_php ($structure);
  
          // Add standard PHP footer
          $result .= XMLDB_PHP_FOOTER;
  
          return $result;
      }
code_tokens: function create_table_php ( $ structure , $ table ) { $ result = '' ; // Validate if we can do it if ( ! $ table = $ structure -> getTable ( $ table ) ) { return false ; } if ( $ table -> getAllErrors ( ) ) { return false ; } // Add the standard PHP header $ result .= XMLDB_PHP_HEADER ; // Add contents $ result .= XMLDB_LINEFEED ; $ result .= '        // Define table ' . $ table -> getName ( ) . ' to be created.' . XMLDB_LINEFEED ; $ result .= '        $table = new xmldb_table(' . "'" . $ table -> getName ( ) . "'" . ');' . XMLDB_LINEFEED ; $ result .= XMLDB_LINEFEED ; $ result .= '        // Adding fields to table ' . $ table -> getName ( ) . '.' . XMLDB_LINEFEED ; // Iterate over each field foreach ( $ table -> getFields ( ) as $ field ) { // The field header, with name $ result .= '        $table->add_field(' . "'" . $ field -> getName ( ) . "', " ; // The field PHP specs $ result .= $ field -> getPHP ( false ) ; // The end of the line $ result .= ');' . XMLDB_LINEFEED ; } // Iterate over each key if ( $ keys = $ table -> getKeys ( ) ) { $ result .= XMLDB_LINEFEED ; $ result .= '        // Adding keys to table ' . $ table -> getName ( ) . '.' . XMLDB_LINEFEED ; foreach ( $ keys as $ key ) { // The key header, with name $ result .= '        $table->add_key(' . "'" . $ key -> getName ( ) . "', " ; // The key PHP specs $ result .= $ key -> getPHP ( ) ; // The end of the line $ result .= ');' . XMLDB_LINEFEED ; } } // Iterate over each index if ( $ indexes = $ table -> getIndexes ( ) ) { $ result .= XMLDB_LINEFEED ; $ result .= '        // Adding indexes to table ' . $ table -> getName ( ) . '.' . XMLDB_LINEFEED ; foreach ( $ indexes as $ index ) { // The index header, with name $ result .= '        $table->add_index(' . "'" . $ index -> getName ( ) . "', " ; // The index PHP specs $ result .= $ index -> getPHP ( ) ; // The end of the line $ result .= ');' . XMLDB_LINEFEED ; } } // Launch the proper DDL $ result .= XMLDB_LINEFEED ; $ result .= '        // Conditionally launch create table for ' . $ table -> getName ( ) . '.' . XMLDB_LINEFEED ; $ result .= '        if (!$dbman->table_exists($table)) {' . XMLDB_LINEFEED ; $ result .= '            $dbman->create_table($table);' . XMLDB_LINEFEED ; $ result .= '        }' . XMLDB_LINEFEED ; // Add the proper upgrade_xxxx_savepoint call $ result .= $ this -> upgrade_savepoint_php ( $ structure ) ; // Add standard PHP footer $ result .= XMLDB_PHP_FOOTER ; return $ result ; }
docstring: This function will generate all the PHP code needed to
  create one table using XMLDB objects and functions
  
  @param xmldb_structure structure object containing all the info
  @param string table table code to be created
  @return string PHP code to be used to create the table
docstring_tokens: This function will generate all the PHP code needed to create one table using XMLDB objects and functions