j4mie/paris

read from slave, then delete from master

shucream0117 opened this issue · 4 comments

Hi.

First, record is read from slave.
(like this↓)

$user = Model::factory('User', 'slave')->find_one(1);

Second, I'd like to delete this record

$user->delete();

but, $user has connection to "slave".
Is there any way to "read from slave, delete from master" ?

@treffynnon

thank you for replying.
sorry, there was a mistake in my question. I modified sentence.

Is the way to "read from slave, delete from master" like following?

$id = 1;
if (Model::factory('User', 'slave')->find_one($id)) { // read from slave
    $user = Model::factory('User', 'master')->find_one($id); // find from master
    $user->delete(); // delete from master
}

ok, thanks