Hi I ended up doing this:

Remove the autoincrement from the table

$ret = $this->Note->query("ALTER TABLE notes MODIFY COLUMN notes_id
BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");

Then insert the data
                $ret = $this->Note->query("INSERT INTO Notes
(notes_id,user_id,date_added,date_modified,details) VALUES ( $notes_id,
$user_id,'$date_added','$date_modified','$details')");

Change the table back to how it originally was.
                $ret = $this->Note->query("ALTER TABLE `hawk_database`.`notes`
MODIFY COLUMN `notes_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT = 66");

And I ended up doing this on the controller instead of using the
model, since in the model it didn't work.

On Jan 16, 11:20 pm, Fabian <[EMAIL PROTECTED]> wrote:
> my query is :
>
> $ret = $this->query("INSERT INTO Notes
> (user_id,date_added,date_modified,details) VALUES (1,'2008-01-01
> 17:22','2008-01-01','Test')");
> Had a typo before.
>
> On Jan 16, 11:06 pm, Fabian <[EMAIL PROTECTED]> wrote:
>
> > 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 cake-php@googlegroups.com
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