title: How to do patchEntity in cakephp
body: <p>Hi I'm making a webpage to get phone number from registerer and make random number as a pin number to save in DB.
  and I want to show registerer to enter the random number.</p>
  
  <p>So I made these code.</p>
  
  <pre><code>class RegistersController extends AppController{
  
      public function index()
      {
          $random = rand(11111,99999);
          $register = $this-&gt;Registers-&gt;newEntity($this-&gt;request-&gt;data);
          if($this-&gt;Registers-&gt;save($register)) {
              $this-&gt;Flash-&gt;success('The Phone number has been sent.');
              $reg = $this-&gt;Registers-&gt;patchEntity($random);
              $this-&gt;Registers-&gt;save($reg);
              return $this-&gt;redirect(['action' =&gt; 'certnum']);
          }
          $this-&gt;set(compact('register'));
      }
  }
  </code></pre>
  
  <p>But somehow It makes fatal error which I have no idea what to do?</p>
  
  <p>Do i have to the random number into array with certain id number or something?</p>
  
  <p>Please help.</p>
  
  <p>Thank you</p>