0
votes

I would like to save internally in a HABTM relation table, i am running cakephp 1.3. Well in fact its save the data into table. but there is a error in the debug. I think its not the correct way.

Cause I have to set this model with primaryKey = NULL, so model.php broke in line 1379 when it read $fInfo = $this->_schema[$this->primaryKey];

my code is=

$vars = array('blogs_files'=>array('blog_id'=>$this->data['Blog']['id'],'file_id'=>$FILEID));
$this->blogs_files->primaryKey = NULL;
$this->blogs_files->save($vars);

have any idea? I have tried with SaveAll() but it worked worse.

1
What is the reason for not having primary keys? - 8vius

1 Answers

1
votes

even your HABTM tables should have a primary key! then it will be no problem to work with those tables

a simple int(10) won't hurt.