The solutions is:
class DATABASE_CONFIG {
var $default = array(
'driver' => 'mysql',
'host' => 'slave.host.ip',
'login' => '....',
'password' => '.....',
'database' => 'my_db'
);
var $master = array(
'driver' => 'mysql',
'host' => 'master.host.ip',
'login' => '....',
'password' => '.....',
'database' => 'my_db'
);
}
class AppModel extends Model {
function save($data = null, $validate = true, $fieldList = array()) {
$this->useDbConfig = 'master';
$result = parent::save($data, $validate, $fieldList);
$this->useDbConfig = 'default';
return $result;
}
function beforeDelete( $cascade=true ) {
$this->useDbConfig = 'master';
return parent::beforeDelete( $cascade );
}
function afterDelete() {
$this->useDbConfig = 'default';
return parent::afterDelete();
}
}
On 27 jan, 15:05, Eduardo Carvalho <[email protected]> wrote:
> this would be very nice if worked correctly. It happens that the
> connection is made before the beforeSave!!!!
> So ... IS NOT SO SIMPLE!
>
> On 27 jan, 13:56, Eduardo Carvalho <[email protected]> wrote:
>
> > I found the answer to this question in:
>
> >http://groups.google.com/group/cake-php/browse_thread/thread/58ea010f...
>
> > On 27 jan, 10:18, Eduardo Carvalho <[email protected]> wrote:
>
> > > I would like to configure my application made in CAKE
> > > toaccessadatabasetoreadandanotherdatabasefor writing.
> > > The framework allows me to do this?
>
> > > Thanks a lot!
>
> > > Eduardo Carvalho
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---