Tuesday, December 17, 2013

Re: Cakephp without Save() function?

hi
may i recommend reading

set your data into an array (e.g. $data = array('data1'=>1,'data2'=>2);

$this->Model->id = $id;

if($this->Model->save($data)){

// success

};

 


On 12 Dec 2013, at 06:18, YOONG SINJIE <sinjie2008@gmail.com> wrote:

May I know , got other way to store the SQL statement, except the Save() function ? I want to do some simple calculation, i want to store the result at database. Anyone having any idea about it ?

public function add() { if ($this->request->is('post')) {
        /// complete calculation             $data1 = (string) $this->request->data['Calculate']['var1'];          $data2 = (string) $this->request->data['Calculate']['var2'];            echo $data1;          echo '<br/>';          echo $data2;            $result = $data1 + $data2;            echo '<br/>';          echo $result;          SQL Statement        mysql_query("INSERT INTO calculate VALUES('$data1','$data2','$result','2')") or die(mysql_error());         // if($this->Calculate->save($this->request->data)){           //     echo'succuful add';             // }      }
}



--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

....................................
Mike Karthäuser
Director, Brightstorm Ltd.

1, Brewery Court
North Street
Bristol
BS3 1JS

mikek@brightstorm.co.uk
www.brightstorm.co.uk
+44(0) 7939252144
....................................

No comments: