Hi all,

I'm trying to create a custom query but I keep getting errors. I tried
this query on mysql command prompt and it works perfectly however in
here it doesn't seem to work.


Create table 'notes' (
notes_id int(20) NOT NULL auto_increment,
'user_id' int(11) NOT NULL,
'date_added' TIMESTAMP NOT NULL,
'date_modified' DATE NOT NULL,
'details'  TEXT NOT NULL,
PRIMARY KEY ('notes_id')
)

class Note extends AppModel{
    var $name = 'Note';
    var $primaryKey = 'notes_id';
}

        function saveNote() {

                $ret = $this->query("INSERT INTO Notes
(user_id,date_added,date_modified,details)  VALUES (1,'2008-01-01
17:22','2008-01-01','Test');");

    }

I'm using a custom query since when I try to use the this->Note-
>Save($this->data); I get and error this is what I tried to do in the
controller:

function save ($user_id = null, $date_added = null, $date_modified=
null, $details = null) {
                $this->data['note']['user_id'] = $user_id;
                $this->data['note']['date_added'] = date("Y-m-d H:i",
strtotime($date_added));
                $this->data['note']['date_modified'] = date("Y-m-d H:i",
strtotime($date_modified));
                $this->data['note']['details'] = $details;

                 if($this->Note->save($this->data)) {
                  echo 'save successful';
                 }
                 else {
                  echo 'no good';

                }

        }

This is the error I get :

        SELECT COUNT(notes_id) AS count FROM `notes` WHERE `notes_id` = 1

I don't know why it tries to do a select where notes_id = 1 since in
the parameters I don't even ask for the notes_id since it's a
autoincrement. This is why I tried the custom query but had no luck
with that either.

Can anyone shed some light on any of the 2 solutions I'm trying to
develop thanks!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to