Hello, I am creating two models on the fly, these models are related by a field, I am trying to relate them but it seems that I was not taking the parameters that I am passing to the moment of creating the model, look;
`
$mainDboObject = new Model();
$mainDboObject->name = ‘MainTable’;
$mainDboObject->alias = ‘MainTable’;
$mainDboObject->useDbConfig = ‘db1’;
$mainDboObject->useTable = $value;
$mainDboObject->primaryKey = ‘id’;
$DiscDboObject = new Model();
$DiscDboObject->name = 'DiscTable';
$DiscDboObject->alias = 'DiscTable';
$DiscDboObject->useDbConfig = 'db1';
$DiscDboObject->useTable = 'C1_' . $value;
$DiscDboObject->primaryKey = 'id';
`
THEN;
$mainDboObject->hasOne = array(
‘DiscTable’ => array(
‘className’ => ‘DiscTable’,
‘foreignKey’ => ‘INDICE’,
)
);
$mainDboObject->Behaviors->attach(‘Containable’);
$mainDboObject->find(‘first’, array(
‘contain’ => array(
‘DiscTable’ => array(
‘fields’ => array(
‘DiscTable.*’
)
)
)
));
I GET THIS: Error: Table disc_tables for model DiscTable was not found in datasource default.
Somebody?? I’m using cakephp 2.9