Closed anyforever closed 3 years ago
@anyforever Like this? https://gist.github.com/kookxiang/9f24b756122ec03c1511
I dont think you can acheive sql replication with just php
@Andrews54757 yes. select from slave, insert/update/delete/... from master
Wouldnt having multiple medoo instances also work?
@anyforever Or you can create a helper class
use Medoo\Medoo;
class Manager {
public $MASTER;
public $SLAVE;
__construct($opt1,$opt2) {
$this->MASTER = new Medoo($opt1);
$this->SLAVE = new Medoo($opt2);
}
select($table, $join, $columns = null, $where = null) {
$this->SLAVE->select($table, $join, $columns, $where);
}
insert($table, $datas) {
$this->MASTER->insert($table, $datas);
}
update($table, $data, $where = null) {
$this->MASTER->update($table, $data, $where);
}
delete($table, $where) {
$this->MASTER->delete($table, $where);
}
replace($table, $columns, $where = null) {
$this->MASTER->replace($table, $columns, $where);
}
}
Dont see why any editing has to be done with medoo. I think its fine.
@Andrews54757 I'll try it. Thanks.
Glad I could help.
Can we support the master-slave mode?