One serious limitation of DMZ appears to be its insistence on only allowing integer ID’s. This is nonsense IMNSOHO. For starters, it’s considered really bad practice these days to let the DB generate your id’s. ![]()
I created a UUID work-around that so far appears to be working pretty well. It may need some tweaking later on, but the good folks at OverZealous should add this naively as soon as possible. A UUID/GUID generator would be a nice addition also. ![]()
Open the datamapper.php file within the libraries folder.
1. Comment out line 581 and add line 582:
// 'rules' => array('integer')
'rules' => array('')
2. Edit lines 738 through 743 as follows:
// if( ! empty($id) && is_numeric($id))
if( ! empty($id) )
{
// $this->get_by_id(intval($id));
$this->get_by_id($id);
}
3. Comment out line 5939
// $item->{$field} = intval($item->{$field});
UPDATE
4. Add the following code to support the insertions of UUIDrelationships:
Lines 4846, 4854 and 4875
$data['id'] = UUID::v4(); // use whatever version of UUID you prefer
$this->db->insert($relationship_table, $data); // existing insert statement
Again, there may be additional intval conversions that I missed in some other files or validation, but you get the picture.
If you are using MySQL, make your id field a CHAR(36) that does not auto-increment.
When saving your objects, do this:
$org = new Org();
// You will probably want to write a class to generate UUID's
$org->id = '7643D300-EEE2-4554-9927-71935BA436A6';
$org->orgname = "My Organization Name";
// need to call this because we're using our own UUID
$org->save_as_new();
To retrieve the record, do this:
$org = new Org();
$org->where('id', '7643D300-EEE2-4554-9927-71935BA436A6')->get();
This seems to work well, but if you find any problems that need to be addressed further, feel free to comment them here! ![]()
Cheers!
-Beau, WebTigers
