original_string: protected function after_update($result) {
          global $DB;
  
          if (!$result) {
              $this->beforeupdate = null;
              return;
          }
  
          // The parent ID has changed, we need to fix all the paths of the children.
          if ($this->beforeupdate->get('parentid') != $this->get('parentid')) {
              $beforepath = $this->beforeupdate->get('path') . $this->get('id') . '/';
  
              $like = $DB->sql_like('path', '?');
              $likesearch = $DB->sql_like_escape($beforepath) . '%';
  
              $table = '{' . self::TABLE . '}';
              $sql = "UPDATE $table SET path = REPLACE(path, ?, ?) WHERE " . $like;
              $DB->execute($sql, array(
                  $beforepath,
                  $this->get('path') . $this->get('id') . '/',
                  $likesearch
              ));
  
              // Resolving sortorder holes left after changing parent.
              $table = '{' . self::TABLE . '}';
              $sql = "UPDATE $table SET sortorder = sortorder -1 "
                      . " WHERE  competencyframeworkid = ? AND parentid = ? AND sortorder > ?";
              $DB->execute($sql, array($this->get('competencyframeworkid'),
                                          $this->beforeupdate->get('parentid'),
                                          $this->beforeupdate->get('sortorder')
                                      ));
          }
  
          $this->beforeupdate = null;
      }
code: protected function after_update($result) {
          global $DB;
  
          if (!$result) {
              $this->beforeupdate = null;
              return;
          }
  
          // The parent ID has changed, we need to fix all the paths of the children.
          if ($this->beforeupdate->get('parentid') != $this->get('parentid')) {
              $beforepath = $this->beforeupdate->get('path') . $this->get('id') . '/';
  
              $like = $DB->sql_like('path', '?');
              $likesearch = $DB->sql_like_escape($beforepath) . '%';
  
              $table = '{' . self::TABLE . '}';
              $sql = "UPDATE $table SET path = REPLACE(path, ?, ?) WHERE " . $like;
              $DB->execute($sql, array(
                  $beforepath,
                  $this->get('path') . $this->get('id') . '/',
                  $likesearch
              ));
  
              // Resolving sortorder holes left after changing parent.
              $table = '{' . self::TABLE . '}';
              $sql = "UPDATE $table SET sortorder = sortorder -1 "
                      . " WHERE  competencyframeworkid = ? AND parentid = ? AND sortorder > ?";
              $DB->execute($sql, array($this->get('competencyframeworkid'),
                                          $this->beforeupdate->get('parentid'),
                                          $this->beforeupdate->get('sortorder')
                                      ));
          }
  
          $this->beforeupdate = null;
      }
code_tokens: protected function after_update ( $ result ) { global $ DB ; if ( ! $ result ) { $ this -> beforeupdate = null ; return ; } // The parent ID has changed, we need to fix all the paths of the children. if ( $ this -> beforeupdate -> get ( 'parentid' ) != $ this -> get ( 'parentid' ) ) { $ beforepath = $ this -> beforeupdate -> get ( 'path' ) . $ this -> get ( 'id' ) . '/' ; $ like = $ DB -> sql_like ( 'path' , '?' ) ; $ likesearch = $ DB -> sql_like_escape ( $ beforepath ) . '%' ; $ table = '{' . self :: TABLE . '}' ; $ sql = "UPDATE $table SET path = REPLACE(path, ?, ?) WHERE " . $ like ; $ DB -> execute ( $ sql , array ( $ beforepath , $ this -> get ( 'path' ) . $ this -> get ( 'id' ) . '/' , $ likesearch ) ) ; // Resolving sortorder holes left after changing parent. $ table = '{' . self :: TABLE . '}' ; $ sql = "UPDATE $table SET sortorder = sortorder -1 " . " WHERE  competencyframeworkid = ? AND parentid = ? AND sortorder > ?" ; $ DB -> execute ( $ sql , array ( $ this -> get ( 'competencyframeworkid' ) , $ this -> beforeupdate -> get ( 'parentid' ) , $ this -> beforeupdate -> get ( 'sortorder' ) ) ) ; } $ this -> beforeupdate = null ; }
docstring: Hook to execute after an update.
  
  @param bool $result Whether or not the update was successful.
  @return void
docstring_tokens: Hook to execute after an update .