Since we could not change CRM behavior we have tried walking on a non conventional path: we had exported some views from CRM database to the SS DB, letting them appear like DO tables (correct name, added ID, ClassName, Created and LastEdited column). Doing so SS views CRM objects like its own DataObjects, and it can work with them. Since the views are simple table select without joins we can also write through them.
CREATE TABLE IF NOT EXISTS `software` (
`ss_id` int(11) NOT NULL AUTO_INCREMENT,
`ClassName` enum('DoSoftware') NOT NULL,
`Created` datetime NOT NULL,
`LastEdited` datetime NOT NULL,
`id` varchar(20) NOT NULL DEFAULT '',
`id_linea` varchar(10) DEFAULT NULL,
[.. snip ..]
PRIMARY KEY (`ss_id`),
UNIQUE KEY `id` (`id`),
KEY `id_linea` (`id_linea`),
KEY `id_linea_2` (`id_linea`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=66 ;
ALTER TABLE `software`
ADD CONSTRAINT `software_ibfk_1` FOREIGN KEY (`id_linea`) REFERENCES `software_linee` (`id`) ON UPDATE CASCADE;
###########################################
############### SS DB:
###########################################
CREATE VIEW DoSoftware AS (
select ss_id as ID,
ClassName,
Created,
LastEdited,
id as ec_id,
id_linea,
[.. snip ..]
from `crm`.`software`
);
###########################################
############### SS CODE:
###########################################
class DoSoftware extends DataObject {
private static $db = array(
'ec_id' => 'Varchar(20)',
'id_linea' => 'Varchar(10)',
[.. snip ..]
);
private static $has_many = array (
'Files' => 'File',
'Demos' => 'File'
);
}
We had some issue with the original foreign key that can not be translated to SS has_one/has_many relationship (software_linee has also been translated into SS DataObject), but we handled them by hand. Everything seems working, what do you think about that?
g4b0