mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 17:29:10 +00:00
added db parameter to the syncing
--HG-- branch : quitta-gsoc-2013
This commit is contained in:
parent
1c6cdfd7a7
commit
2d1a07c787
4 changed files with 16 additions and 17 deletions
|
@ -18,33 +18,31 @@ class Sync{
|
|||
$dbl = new DBLayer("lib");
|
||||
$statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache");
|
||||
$rows = $statement->fetchAll();
|
||||
$dbs = new DBLayer("shard");
|
||||
foreach ($rows as $record) {
|
||||
|
||||
$db = new DBLayer($record['db']);
|
||||
switch($record['type']) {
|
||||
case 'createPermissions':
|
||||
case 'change_pass':
|
||||
$decode = json_decode($record['query']);
|
||||
$values = array('user' => $decode[0], 'pass' => $decode[1]);
|
||||
//make connection with and put into shard db & delete from the lib
|
||||
$dbs->execute("UPDATE user SET Password = :pass WHERE Login = :user",$values);
|
||||
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
||||
$db->execute("UPDATE user SET Password = :pass WHERE Login = :user",$values);
|
||||
break;
|
||||
case 'change_mail':
|
||||
$decode = json_decode($record['query']);
|
||||
$values = array('user' => $decode[0], 'mail' => $decode[1]);
|
||||
//make connection with and put into shard db & delete from the lib
|
||||
$dbs->execute("UPDATE user SET Email = :mail WHERE Login = :user",$values);
|
||||
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
||||
$db->execute("UPDATE user SET Email = :mail WHERE Login = :user",$values);
|
||||
break;
|
||||
case 'createUser':
|
||||
$decode = json_decode($record['query']);
|
||||
$values = array('login' => $decode[0], 'pass' => $decode[1], 'mail' => $decode[2] );
|
||||
//make connection with and put into shard db & delete from the lib
|
||||
$dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$values);
|
||||
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
||||
$db->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$values);
|
||||
break;
|
||||
}
|
||||
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
||||
}
|
||||
print('Syncing completed');
|
||||
}
|
||||
|
|
|
@ -296,8 +296,8 @@ class Users{
|
|||
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
||||
try {
|
||||
$dbl = new DBLayer("lib");
|
||||
$dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser",
|
||||
"query" => json_encode(array($values["name"],$values["pass"],$values["mail"]))));
|
||||
$dbl->execute("INSERT INTO ams_querycache (type, query, db) VALUES (:type, :query, :db)",array("type" => "createUser",
|
||||
"query" => json_encode(array($values["name"],$values["pass"],$values["mail"])), "db" => "shard"));
|
||||
ticket_user::createTicketUser( $user_id , 1 );
|
||||
return "shardoffline";
|
||||
}catch (PDOException $e) {
|
||||
|
@ -380,8 +380,8 @@ class Users{
|
|||
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
||||
try {
|
||||
$dbl = new DBLayer("lib");
|
||||
$dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "change_pass",
|
||||
"query" => json_encode(array($values["user"],$values["pass"]))));
|
||||
$dbl->execute("INSERT INTO ams_querycache (type, query, db) VALUES (:type, :query, :db)",array("type" => "change_pass",
|
||||
"query" => json_encode(array($values["user"],$values["pass"])), "db" => "shard"));
|
||||
return "shardoffline";
|
||||
}catch (PDOException $e) {
|
||||
return "liboffline";
|
||||
|
@ -403,8 +403,8 @@ class Users{
|
|||
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
||||
try {
|
||||
$dbl = new DBLayer("lib");
|
||||
$dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "change_mail",
|
||||
"query" => json_encode(array($values["user"],$values["mail"]))));
|
||||
$dbl->execute("INSERT INTO ams_querycache (type, query, db) VALUES (:type, :query, :db)",array("type" => "change_mail",
|
||||
"query" => json_encode(array($values["user"],$values["mail"])), "db" => "shard"));
|
||||
return "shardoffline";
|
||||
}catch (PDOException $e) {
|
||||
return "liboffline";
|
||||
|
|
|
@ -19,7 +19,7 @@ $cfg['db']['lib']['name'] = 'ryzom_ams_lib';
|
|||
$cfg['db']['lib']['user'] = 'shard';
|
||||
$cfg['db']['lib']['pass'] = '';
|
||||
|
||||
$cfg['db']['shard']['host'] = 'localhosti';
|
||||
$cfg['db']['shard']['host'] = 'localhost';
|
||||
$cfg['db']['shard']['port'] = '3306';
|
||||
$cfg['db']['shard']['name'] = 'nel';
|
||||
$cfg['db']['shard']['user'] = 'shard';
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
CREATE TABLE ams_querycache (
|
||||
`SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`type` VARCHAR( 64 ) NOT NULL ,
|
||||
`query` VARCHAR( 512 ) NOT NULL
|
||||
`query` VARCHAR( 512 ) NOT NULL,
|
||||
`db` VARCHAR( 80 ) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue