\DB\Mongo\Mapper is not updating the record

25 views
Skip to first unread message

Muhammad Shahzad

unread,
Apr 27, 2017, 2:58:55 AM4/27/17
to Fat-Free Framework
Hi,

I have an issue, \DB\Mongo\Mapper is inserting new recored instead of updating current record.
I followed these instructions.
https://fatfreeframework.com/3.6/mongo-mapper

myclass.php

<?php
namespace Model;

class MyClass extends  \DB\Mongo\Mapper  {

    public $transid, $tempStatus;

    public function __construct() {
        parent::__construct( \Base::instance()->get('MongoDB'), 'transactions' );

    }

   private function myFunction($dataArr){
        $this->transid  = new \MongoId($dataArr['id']); // $dataArr['id'] = 58f3f0a28e5bbfb808bf6784
        $dataFound=$this->load(array('_id'=>$this->transid));
        if (empty($dataFound))
                continue;
        if($dataFound->status)
                     $this->tempStatus = $dataFound->status;
           
         $this->resolved  = '1';
         $this->approvedBy ='1';
         $this->status = (string)$this->tempStatus;
         if($res = $this->update()){
             echo "After Updated<pre>";
             print_r($res);
         }
   }

}



Reply all
Reply to author
Forward
0 new messages