original_string: public function getFieldUses($tablename, $fieldname) {
  
          $uses = array();
  
          // Check if any key in the table is using it
          $table = $this->getTable($tablename);
          if ($keys = $table->getKeys()) {
              foreach ($keys as $key) {
                  if (in_array($fieldname, $key->getFields()) ||
                      in_array($fieldname, $key->getRefFields())) {
                          $uses[] = 'table ' . $table->getName() . ' key ' . $key->getName();
                  }
              }
          }
          // Check if any index in the table is using it
          $table = $this->getTable($tablename);
          if ($indexes = $table->getIndexes()) {
              foreach ($indexes as $index) {
                  if (in_array($fieldname, $index->getFields())) {
                      $uses[] = 'table ' . $table->getName() . ' index ' . $index->getName();
                  }
              }
          }
          // Check if some foreign key in the whole structure is using it
          // By comparing the reftable and refields with the field)
          if ($this->tables) {
              foreach ($this->tables as $table) {
                  $keys = $table->getKeys();
                  if ($keys) {
                      foreach ($keys as $key) {
                          if ($key->getType() == XMLDB_KEY_FOREIGN) {
                              if ($tablename == $key->getRefTable()) {
                                  $reffieds = $key->getRefFields();
                                  if (in_array($fieldname, $key->getRefFields())) {
                                      $uses[] = 'table ' . $table->getName() . ' key ' . $key->getName();
                                  }
                              }
                          }
                      }
                  }
              }
          }
  
          // Return result
          if (!empty($uses)) {
              return $uses;
          } else {
              return false;
          }
      }
code: public function getFieldUses($tablename, $fieldname) {
  
          $uses = array();
  
          // Check if any key in the table is using it
          $table = $this->getTable($tablename);
          if ($keys = $table->getKeys()) {
              foreach ($keys as $key) {
                  if (in_array($fieldname, $key->getFields()) ||
                      in_array($fieldname, $key->getRefFields())) {
                          $uses[] = 'table ' . $table->getName() . ' key ' . $key->getName();
                  }
              }
          }
          // Check if any index in the table is using it
          $table = $this->getTable($tablename);
          if ($indexes = $table->getIndexes()) {
              foreach ($indexes as $index) {
                  if (in_array($fieldname, $index->getFields())) {
                      $uses[] = 'table ' . $table->getName() . ' index ' . $index->getName();
                  }
              }
          }
          // Check if some foreign key in the whole structure is using it
          // By comparing the reftable and refields with the field)
          if ($this->tables) {
              foreach ($this->tables as $table) {
                  $keys = $table->getKeys();
                  if ($keys) {
                      foreach ($keys as $key) {
                          if ($key->getType() == XMLDB_KEY_FOREIGN) {
                              if ($tablename == $key->getRefTable()) {
                                  $reffieds = $key->getRefFields();
                                  if (in_array($fieldname, $key->getRefFields())) {
                                      $uses[] = 'table ' . $table->getName() . ' key ' . $key->getName();
                                  }
                              }
                          }
                      }
                  }
              }
          }
  
          // Return result
          if (!empty($uses)) {
              return $uses;
          } else {
              return false;
          }
      }
code_tokens: public function getFieldUses ( $ tablename , $ fieldname ) { $ uses = array ( ) ; // Check if any key in the table is using it $ table = $ this -> getTable ( $ tablename ) ; if ( $ keys = $ table -> getKeys ( ) ) { foreach ( $ keys as $ key ) { if ( in_array ( $ fieldname , $ key -> getFields ( ) ) || in_array ( $ fieldname , $ key -> getRefFields ( ) ) ) { $ uses [ ] = 'table ' . $ table -> getName ( ) . ' key ' . $ key -> getName ( ) ; } } } // Check if any index in the table is using it $ table = $ this -> getTable ( $ tablename ) ; if ( $ indexes = $ table -> getIndexes ( ) ) { foreach ( $ indexes as $ index ) { if ( in_array ( $ fieldname , $ index -> getFields ( ) ) ) { $ uses [ ] = 'table ' . $ table -> getName ( ) . ' index ' . $ index -> getName ( ) ; } } } // Check if some foreign key in the whole structure is using it // By comparing the reftable and refields with the field) if ( $ this -> tables ) { foreach ( $ this -> tables as $ table ) { $ keys = $ table -> getKeys ( ) ; if ( $ keys ) { foreach ( $ keys as $ key ) { if ( $ key -> getType ( ) == XMLDB_KEY_FOREIGN ) { if ( $ tablename == $ key -> getRefTable ( ) ) { $ reffieds = $ key -> getRefFields ( ) ; if ( in_array ( $ fieldname , $ key -> getRefFields ( ) ) ) { $ uses [ ] = 'table ' . $ table -> getName ( ) . ' key ' . $ key -> getName ( ) ; } } } } } } } // Return result if ( ! empty ( $ uses ) ) { return $ uses ; } else { return false ; } }
docstring: This function returns the number of uses of one field inside
  a whole xmldb_structure. Useful to detect if the field must be
  locked. Return false if no uses are found.
  @param string $tablename
  @param string $fieldname
  @return mixed
docstring_tokens: This function returns the number of uses of one field inside a whole xmldb_structure . Useful to detect if the field must be locked . Return false if no uses are found .