protected function doUpdate($dataset, array $condFields, $updateNulls = false)
    {
        !$this->useTransaction ?: $this->db->getTransaction(true)->start();

        try {
            foreach ($dataset as $k => $data) {
                if (!$data instanceof $this->dataClass) {
                    $data = $this->bindData($data);
                }

                // If data is entity object, try cast values first.
                if ($data instanceof Entity) {
                    $data = $this->castForStore($data);
                }

                $entity = new Entity($this->getFields($this->table), $data);

                if ($updateNulls) {
                    $entity = $this->validValue($entity);
                }

                $this->db->getWriter()->updateOne($this->table, $entity, $condFields, $updateNulls);

                $dataset[$k] = $data;
            }
        } catch (\Throwable $e) {
            !$this->useTransaction ?: $this->db->getTransaction(true)->rollback();

            throw $e;
        }

        !$this->useTransaction ?: $this->db->getTransaction(true)->commit();

        return $dataset;
    }
protected function doUpdate($dataset, array $condFields, $updateNulls = false)
    {
        !$this->useTransaction ?: $this->db->getTransaction(true)->start();

        try {
            foreach ($dataset as $k => $data) {
                if (!$data instanceof $this->dataClass) {
                    $data = $this->bindData($data);
                }

                // If data is entity object, try cast values first.
                if ($data instanceof Entity) {
                    $data = $this->castForStore($data);
                }

                $entity = new Entity($this->getFields($this->table), $data);

                if ($updateNulls) {
                    $entity = $this->validValue($entity);
                }

                $this->db->getWriter()->updateOne($this->table, $entity, $condFields, $updateNulls);

                $dataset[$k] = $data;
            }
        } catch (\Throwable $e) {
            !$this->useTransaction ?: $this->db->getTransaction(true)->rollback();

            throw $e;
        }

        !$this->useTransaction ?: $this->db->getTransaction(true)->commit();

        return $dataset;
    }
protected function doUpdate ( $ dataset , array $ condFields , $ updateNulls = false ) { ! $ this -> useTransaction ? : $ this -> db -> getTransaction ( true ) -> start ( ) ; try { foreach ( $ dataset as $ k => $ data ) { if ( ! $ data instanceof $ this -> dataClass ) { $ data = $ this -> bindData ( $ data ) ; } // If data is entity object, try cast values first. if ( $ data instanceof Entity ) { $ data = $ this -> castForStore ( $ data ) ; } $ entity = new Entity ( $ this -> getFields ( $ this -> table ) , $ data ) ; if ( $ updateNulls ) { $ entity = $ this -> validValue ( $ entity ) ; } $ this -> db -> getWriter ( ) -> updateOne ( $ this -> table , $ entity , $ condFields , $ updateNulls ) ; $ dataset [ $ k ] = $ data ; } } catch ( \ Throwable $ e ) { ! $ this -> useTransaction ? : $ this -> db -> getTransaction ( true ) -> rollback ( ) ; throw $ e ; } ! $ this -> useTransaction ? : $ this -> db -> getTransaction ( true ) -> commit ( ) ; return $ dataset ; }
Do update action.

@param   mixed $dataset      Data set contain data we want to update.
@param   array $condFields   The where condition tell us record exists or not, if not set,
will use primary key instead.
@param   bool  $updateNulls  Update empty fields or not.

@return  mixed

@throws \Exception
@throws \Throwable
Do update action .