original_string: protected function _update($entity, $data)
      {
          $primaryColumns = (array)$this->getPrimaryKey();
          $primaryKey = $entity->extract($primaryColumns);
  
          $data = array_diff_key($data, $primaryKey);
          if (empty($data)) {
              return $entity;
          }
  
          if (count($primaryColumns) === 0) {
              $entityClass = get_class($entity);
              $table = $this->getTable();
              $message = "Cannot update `$entityClass`. The `$table` has no primary key.";
              throw new InvalidArgumentException($message);
          }
  
          if (!$entity->has($primaryColumns)) {
              $message = 'All primary key value(s) are needed for updating, ';
              $message .= get_class($entity) . ' is missing ' . implode(', ', $primaryColumns);
              throw new InvalidArgumentException($message);
          }
  
          $query = $this->query();
          $statement = $query->update()
              ->set($data)
              ->where($primaryKey)
              ->execute();
  
          $success = false;
          if ($statement->errorCode() === '00000') {
              $success = $entity;
          }
          $statement->closeCursor();
  
          return $success;
      }
code: protected function _update($entity, $data)
      {
          $primaryColumns = (array)$this->getPrimaryKey();
          $primaryKey = $entity->extract($primaryColumns);
  
          $data = array_diff_key($data, $primaryKey);
          if (empty($data)) {
              return $entity;
          }
  
          if (count($primaryColumns) === 0) {
              $entityClass = get_class($entity);
              $table = $this->getTable();
              $message = "Cannot update `$entityClass`. The `$table` has no primary key.";
              throw new InvalidArgumentException($message);
          }
  
          if (!$entity->has($primaryColumns)) {
              $message = 'All primary key value(s) are needed for updating, ';
              $message .= get_class($entity) . ' is missing ' . implode(', ', $primaryColumns);
              throw new InvalidArgumentException($message);
          }
  
          $query = $this->query();
          $statement = $query->update()
              ->set($data)
              ->where($primaryKey)
              ->execute();
  
          $success = false;
          if ($statement->errorCode() === '00000') {
              $success = $entity;
          }
          $statement->closeCursor();
  
          return $success;
      }
code_tokens: protected function _update ( $ entity , $ data ) { $ primaryColumns = ( array ) $ this -> getPrimaryKey ( ) ; $ primaryKey = $ entity -> extract ( $ primaryColumns ) ; $ data = array_diff_key ( $ data , $ primaryKey ) ; if ( empty ( $ data ) ) { return $ entity ; } if ( count ( $ primaryColumns ) === 0 ) { $ entityClass = get_class ( $ entity ) ; $ table = $ this -> getTable ( ) ; $ message = "Cannot update `$entityClass`. The `$table` has no primary key." ; throw new InvalidArgumentException ( $ message ) ; } if ( ! $ entity -> has ( $ primaryColumns ) ) { $ message = 'All primary key value(s) are needed for updating, ' ; $ message .= get_class ( $ entity ) . ' is missing ' . implode ( ', ' , $ primaryColumns ) ; throw new InvalidArgumentException ( $ message ) ; } $ query = $ this -> query ( ) ; $ statement = $ query -> update ( ) -> set ( $ data ) -> where ( $ primaryKey ) -> execute ( ) ; $ success = false ; if ( $ statement -> errorCode ( ) === '00000' ) { $ success = $ entity ; } $ statement -> closeCursor ( ) ; return $ success ; }
docstring: Auxiliary function to handle the update of an entity's data in the table
  
  @param \Cake\Datasource\EntityInterface $entity the subject entity from were $data was extracted
  @param array $data The actual data that needs to be saved
  @return \Cake\Datasource\EntityInterface|bool
  @throws \InvalidArgumentException When primary key data is missing.
docstring_tokens: Auxiliary function to handle the update of an entity s data in the table