hi
may i recommend reading
http://book.cakephp.org/2.0/en/models/saving-your-data.html
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 <[email protected]> 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 [email protected].
> To post to this group, send email to [email protected].
> 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
[email protected]
www.brightstorm.co.uk
+44(0) 7939252144
....................................
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.