I have a very simple join model in cake php. I'm encountering a bug where the ID for each new record inserted is "".
<?php
App::uses('AppModel', 'Model');
/**
* Subscriber Model
*
* @property ChallengeMember $ChallengeMember
* @property Activity $Activity
*/
class Subscriber extends AppModel {
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'ChallengeMember' => array(
'className' => 'ChallengeMember',
'foreignKey' => 'challenge_member_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Activity' => array(
'className' => 'Activity',
'foreignKey' => 'activity_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
This is what the table looks like:
public $fields = array(
'id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36, 'key' => 'primary', 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'activity_id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 37, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'challenge_member_id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 37, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'indexes' => array(
),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB')
);
When testing,
$this->Subscriber->create(array('challenge_member_id' => 'test123456','ChallengeMember.first_time_in_dash' => '1'));
$this->Subscriber->save();
Debugger::dump($this->Subscriber->find('all'));
Outputs
array(
'Subscriber' => array(
'id' => '',
'challenge_member_id' => 'test123456',
'activity_id' => '',
'created' => '2014-07-16 18:45:14'
)
........
As you can see cake is failing too autogen the ID, which is out of character to the rest of my models. Any ideas ? I've re-baked the model and test fixtures but no joy!