original_string: public function save()
      {
          $this->beforeSave();
          /**
           * If the primary key is empty, this is an INSERT of a new row.
           * Otherwise check primary key updated or not, if it changed - INSERT
           * otherwise UPDATE
           */
          if (!\count(\array_filter($this->getPrimaryKey()))) {
              $result = $this->doInsert();
          } elseif (\count(\array_diff_assoc($this->getPrimaryKey(), $this->clean))) {
              $result = $this->doInsert();
          } else {
              $result = $this->doUpdate();
          }
          $this->afterSave();
          return $result;
      }
code: public function save()
      {
          $this->beforeSave();
          /**
           * If the primary key is empty, this is an INSERT of a new row.
           * Otherwise check primary key updated or not, if it changed - INSERT
           * otherwise UPDATE
           */
          if (!\count(\array_filter($this->getPrimaryKey()))) {
              $result = $this->doInsert();
          } elseif (\count(\array_diff_assoc($this->getPrimaryKey(), $this->clean))) {
              $result = $this->doInsert();
          } else {
              $result = $this->doUpdate();
          }
          $this->afterSave();
          return $result;
      }
code_tokens: public function save ( ) { $ this -> beforeSave ( ) ; /**
           * If the primary key is empty, this is an INSERT of a new row.
           * Otherwise check primary key updated or not, if it changed - INSERT
           * otherwise UPDATE
           */ if ( ! \ count ( \ array_filter ( $ this -> getPrimaryKey ( ) ) ) ) { $ result = $ this -> doInsert ( ) ; } elseif ( \ count ( \ array_diff_assoc ( $ this -> getPrimaryKey ( ) , $ this -> clean ) ) ) { $ result = $ this -> doInsert ( ) ; } else { $ result = $ this -> doUpdate ( ) ; } $ this -> afterSave ( ) ; return $ result ; }
docstring: Saves the properties to the database.
  
  This performs an intelligent insert/update, and reloads the
  properties with fresh data from the table on success.
  
  @return mixed The primary key value(s), as an associative array if the
  key is compound, or a scalar if the key is single-column
  @throws DbException
  @throws InvalidPrimaryKeyException
  @throws TableNotFoundException
docstring_tokens: Saves the properties to the database .