Example #1
0
 public function getOnesql($where)
 {
     $m = new PSys_SynRule();
     $sql = $m->getsqlDetails($where);
     return $sql;
 }
Example #2
0
 public function DBonesynAction($citeid, $sqlid)
 {
     $m = new PSys_SynModel();
     $d = new PSys_SynRule();
     $error = array();
     $error['error'] = true;
     foreach ($citeid as $id) {
         $cites = array();
         $where = array('id' => $id);
         $cites = $m->GetOne($where, '*');
         $swhere = array('id' => $sqlid);
         $sql = $d->GetOnesql('*', $swhere);
         $db_config["hostname"] = $cites['citeip'];
         //服务器地址
         $db_config["username"] = $cites['name'];
         //数据库用户名
         $db_config["password"] = $cites['password'];
         //数据库密码
         $db_config["database"] = $sql['database'];
         //数据库名称
         $db_config["charset"] = "utf8";
         //数据库编码
         $db_config["pconnect"] = 0;
         //开启持久连接
         $db_config["log"] = 0;
         //开启日志
         $db_config["logfilepath"] = './';
         //开启日志
         $db = new PSys_dbsynRule($db_config);
         $result = $db->query($sql['sqlcontent']);
         if (!$result) {
             $sqlwhere = array('id' => $sqlid);
             $data = array('error' => $sql['error'] . ',' . $id);
             $d->Update($data, $sqlwhere);
             $error['error'] = false;
             $error['ercontent'] .= "SQL语句同步失败编号:" . $sql['id'] . "。";
         } else {
             $sqlwhere = array('id' => $sqlid);
             $data = array('siteid' => $sql['siteid'] . ',' . $id);
             $d->Update($data, $sqlwhere);
         }
     }
     return $error;
 }