original_string: public function insert_record($table, $dataobject, $returnid=true, $bulk=false) {
          $dataobject = (array)$dataobject;
  
          $columns = $this->get_columns($table);
          if (empty($columns)) {
              throw new dml_exception('ddltablenotexist', $table);
          }
  
          $cleaned = array();
  
          foreach ($dataobject as $field=>$value) {
              if ($field === 'id') {
                  continue;
              }
              if (!isset($columns[$field])) { // Non-existing table field, skip it
                  continue;
              }
              $column = $columns[$field];
              $cleaned[$field] = $this->normalise_value($column, $value);
          }
  
          return $this->insert_record_raw($table, $cleaned, $returnid, $bulk);
      }
code: public function insert_record($table, $dataobject, $returnid=true, $bulk=false) {
          $dataobject = (array)$dataobject;
  
          $columns = $this->get_columns($table);
          if (empty($columns)) {
              throw new dml_exception('ddltablenotexist', $table);
          }
  
          $cleaned = array();
  
          foreach ($dataobject as $field=>$value) {
              if ($field === 'id') {
                  continue;
              }
              if (!isset($columns[$field])) { // Non-existing table field, skip it
                  continue;
              }
              $column = $columns[$field];
              $cleaned[$field] = $this->normalise_value($column, $value);
          }
  
          return $this->insert_record_raw($table, $cleaned, $returnid, $bulk);
      }
code_tokens: public function insert_record ( $ table , $ dataobject , $ returnid = true , $ bulk = false ) { $ dataobject = ( array ) $ dataobject ; $ columns = $ this -> get_columns ( $ table ) ; if ( empty ( $ columns ) ) { throw new dml_exception ( 'ddltablenotexist' , $ table ) ; } $ cleaned = array ( ) ; foreach ( $ dataobject as $ field => $ value ) { if ( $ field === 'id' ) { continue ; } if ( ! isset ( $ columns [ $ field ] ) ) { // Non-existing table field, skip it continue ; } $ column = $ columns [ $ field ] ; $ cleaned [ $ field ] = $ this -> normalise_value ( $ column , $ value ) ; } return $ this -> insert_record_raw ( $ table , $ cleaned , $ returnid , $ bulk ) ; }
docstring: Insert a record into a table and return the "id" field if required.
  
  Some conversions and safety checks are carried out. Lobs are supported.
  If the return ID isn't required, then this just reports success as true/false.
  $data is an object containing needed data
  @param string $table The database table to be inserted into
  @param object $data A data object with values for one or more fields in the record
  @param bool $returnid Should the id of the newly created record entry be returned? If this option is not requested then true/false is returned.
  @return bool|int true or new id
  @throws dml_exception A DML specific exception is thrown for any errors.
docstring_tokens: Insert a record into a table and return the id field if required .