Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
shanliu committed Nov 29, 2019
1 parent 4ea0121 commit c326061
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/common/classes/LSYS/Database/SlaveQueryCheck.php
Expand Up @@ -34,10 +34,14 @@ public function allowSlave($sql){
* @param string $table_schema 默认数据库名
* @param string $sql
*/
public function execNotify($table_schema,$sql){
if($this->cache->delayed()<=0||!$sql)return;
public function execNotify(Prepare $prepare,$connect){
$sql=$prepare->lastQuery();
if($this->cache->delayed()<=0
||$prepare->affectedRows()<=0
||empty($sql))return;
$table=$this->parse->execParseTable($sql);
if(empty($table))return;
$table_schema=$prepare->db()->getConnectManager()->schema($connect);
if(!empty($table_schema)){
$add=[];
foreach ($table as $v){
Expand Down
2 changes: 1 addition & 1 deletion src/driver-mysqli/classes/LSYS/Database/MYSQLi/Prepare.php
Expand Up @@ -192,7 +192,7 @@ public function exec(){
$this->event_manager&&$this->event_manager->dispatch(DBEvent::sqlOk($this->sql,true));
break;
}
$this->slave_check&&$this->slave_check->execNotify($connect_mgr->schema($this->connect),$this->sql);
$this->slave_check&&$this->slave_check->execNotify($this,$this->connect);
$this->affected_rows=$this->connect->affected_rows;
$this->insert_id=$this->connect->insert_id;
$this->event_manager&&$this->event_manager->dispatch(DBEvent::sqlEnd($this->sql,true));
Expand Down
2 changes: 1 addition & 1 deletion src/driver-pdo/classes/LSYS/Database/PDO/Prepare.php
Expand Up @@ -179,7 +179,7 @@ public function exec(){
$this->event_manager&&$this->event_manager->dispatch(DBEvent::sqlOk($this->sql,true));
break;
}
$this->slave_check&&$this->slave_check->execNotify($this->db->getConnectManager()->schema($this->connect),$this->query_sql);
$this->slave_check&&$this->slave_check->execNotify($this,$this->connect);
$this->insert_id=$this->connect->lastInsertId();
$this->event_manager&&$this->event_manager->dispatch(DBEvent::sqlEnd($this->sql,true));
return true;
Expand Down

0 comments on commit c326061

Please sign in to comment.