[eluser]brent.fontaine[/eluser]
Hello, I have hit a wall here and hope someone can help me. This might be right under my nose....
I have created a number of objects that relate back to a phone object, and use one join table. My DataMapper config does not negate the default cascade_delete (nor do any of my models), and my database does not have any 'cascade' actions on any of my tables. There is no production-cache either.
Code:
/**
* Phone model...
*/
var $model = 'phone';
var $table = 'phones';
var $has_one = array(
'individual' => array('join_table' => 'jn_phones'),
'branch' => array('join_table' => 'jn_phones'),
.... etc ...
var $validation = array(
'Number' => array(
'rules' => array('clean_phone','required'),
'get_rules' => array('format_phone'),
'label' => 'Phone Number'
),
);
/**
* Individual model...
*/
var $model = 'individual';
var $table = 'individuals';
var $has_many = array(
'phone' => array('join_table' => 'jn_phones'),
'location' => array('join_table' => 'jn_locations'),
'note' => array('join_table' => 'jn_notes'),
);
I have tried to delete a Phone record a couple of different ways, and they all end with the same result:
Code:
/**
* Method 1...
*/
$Phone = new Phone($Phone_id);
$Phone->delete();
/**
* Method 2...
*/
$Individual->phone->where('id',$Phone_id)->get();
if ( ! $Individual->phone->delete() ){
array_push($this->data, $Individual->phone->error->all);
echo json_encode($this->data);
}
They end up with the same results. The Phone record remains intact, but the record in jn_phones is deleted, resulting in orphaned records. I tried this on a remote MySQL server, as well as a local XAMPP-MySQL server. There are no errors, and Datamapper returns TRUE when I delete().
Am I missing something incredibly simple? I would love it if there is a very simple fix that I overlooked. Thanks in advance.