More PgSql updates

This commit is contained in:
Pinga 2023-12-13 07:22:24 +02:00
parent 8aa16110d5
commit b9cab663e0
11 changed files with 26 additions and 32 deletions

View file

@ -73,7 +73,7 @@ try {
$to = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetchColumn();
$stmt_insert_statement = $dbh->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,from,to,amount) VALUES(?,CURRENT_TIMESTAMP,?,?,?,?,?,?)");
$stmt_insert_statement = $dbh->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,fromS,toS,amount) VALUES(?,CURRENT_TIMESTAMP,?,?,?,?,?,?)");
$stmt_insert_statement->execute([$reid, 'transfer', $name, $date_add, $from, $to, $price]);
$stmt_select_domain = $dbh->prepare("SELECT id,registrant,crdate,exdate,lastupdate,clid,crid,upid,trdate,trstatus,reid,redate,acid,acdate,transfer_exdate FROM domain WHERE name = ? LIMIT 1");

View file

@ -51,7 +51,7 @@ try {
$dbh->exec("UPDATE registrar SET accountBalance = (accountBalance - $price) WHERE id = '$clid'");
$dbh->exec("INSERT INTO payment_history (registrar_id, date, description, amount) VALUES('$clid', CURRENT_TIMESTAMP, 'autoRenew domain $name for period 12 MONTH', '-$price')");
list($to) = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetch(PDO::FETCH_NUM);
$sth = $dbh->prepare("INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, from, to, amount) VALUES(?, CURRENT_TIMESTAMP, ?, ?, ?, ?, ?, ?)");
$sth = $dbh->prepare("INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, fromS, toS, amount) VALUES(?, CURRENT_TIMESTAMP, ?, ?, ?, ?, ?, ?)");
$sth->execute([$clid, 'autoRenew', $name, '12', $exdate, $to, $price]);
if (!$dbh->query("SELECT id FROM statistics WHERE date = CURDATE()")->fetchColumn()) {
$dbh->exec("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())");

View file

@ -562,8 +562,8 @@ class DomainsController extends Controller
'command' => 'create',
'domain_name' => $domainName,
'length_in_months' => $date_add,
'from' => $from,
'to' => $to,
'fromS' => $from,
'toS' => $to,
'amount' => $price
]
);
@ -1424,8 +1424,8 @@ class DomainsController extends Controller
'command' => 'renew',
'domain_name' => $domainName,
'length_in_months' => $date_add,
'from' => $from,
'to' => $to,
'fromS' => $from,
'toS' => $to,
'amount' => $price
]
);
@ -2277,8 +2277,8 @@ class DomainsController extends Controller
'command' => 'transfer',
'domain_name' => $domainName,
'length_in_months' => $date_add,
'from' => $from,
'to' => $to,
'fromS' => $from,
'toS' => $to,
'amount' => $price
]
);
@ -2603,8 +2603,8 @@ class DomainsController extends Controller
'command' => 'restore',
'domain_name' => $domainName,
'length_in_months' => 0,
'from' => $from,
'to' => $from,
'fromS' => $from,
'toS' => $from,
'amount' => $restore_price
]
);
@ -2617,8 +2617,8 @@ class DomainsController extends Controller
'command' => 'renew',
'domain_name' => $domainName,
'length_in_months' => 12,
'from' => $from,
'to' => $to,
'fromS' => $from,
'toS' => $to,
'amount' => $renew_price
]
);

View file

@ -108,8 +108,8 @@ class FinancialsController extends Controller
'command' => 'create',
'domain_name' => 'deposit',
'length_in_months' => 0,
'from' => $date,
'to' => $date,
'fromS' => $date,
'toS' => $date,
'amount' => $amount
]
);
@ -226,8 +226,8 @@ class FinancialsController extends Controller
'command' => 'create',
'domain_name' => 'deposit',
'length_in_months' => 0,
'from' => $date,
'to' => $date,
'fromS' => $date,
'toS' => $date,
'amount' => $amount
]
);

View file

@ -29,8 +29,8 @@
{title:"Command", field:"command", headerSort:true, responsive:2},
{title:"Domain", field:"domain_name", headerSort:false, download:false, responsive:0},
{title:"Length", field:"length_in_months", headerSort:true, responsive:2},
{title:"From", field:"from", headerSort:true, responsive:2},
{title:"To", field:"to", headerSort:true, responsive:2},
{title:"From", field:"fromS", headerSort:true, responsive:2},
{title:"To", field:"toS", headerSort:true, responsive:2},
{title:"Amount", field:"amount", headerSort:false, download:false, responsive:2},
],
placeholder:function(){

View file

@ -168,8 +168,8 @@ CREATE TABLE IF NOT EXISTS `registry`.`statement` (
`command` enum('create','renew','transfer','restore','autoRenew') NOT NULL default 'create',
`domain_name` varchar(68) NOT NULL,
`length_in_months` tinyint(3) unsigned NOT NULL,
`from` datetime(3) NOT NULL,
`to` datetime(3) NOT NULL,
`fromS` datetime(3) NOT NULL,
`toS` datetime(3) NOT NULL,
`amount` decimal(12,2) NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `statement_ibfk_1` FOREIGN KEY (`registrar_id`) REFERENCES `registrar` (`id`) ON DELETE RESTRICT

View file

@ -174,8 +174,8 @@ CREATE TABLE registry.statement (
"command" varchar CHECK ("command" IN ( 'create','renew','transfer','restore','autoRenew' )) NOT NULL default 'create',
"domain_name" varchar(68) NOT NULL,
"length_in_months" smallint CHECK ("length_in_months" >= 0) NOT NULL,
"from" timestamp(3) without time zone NOT NULL,
"to" timestamp(3) without time zone NOT NULL,
"fromS" timestamp(3) without time zone NOT NULL,
"toS" timestamp(3) without time zone NOT NULL,
"amount" decimal(12,2) NOT NULL,
primary key ("id")
);

View file

@ -1174,7 +1174,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
$selectDomainDatesStmt->execute([':name' => $domainName]);
[$from, $to] = $selectDomainDatesStmt->fetch(PDO::FETCH_NUM);
$statementStmt = $db->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,from,to,amount) VALUES(:registrar_id,CURRENT_TIMESTAMP(3),:cmd,:name,:date_add,:from,:to,:price)");
$statementStmt = $db->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,fromS,toS,amount) VALUES(:registrar_id,CURRENT_TIMESTAMP(3),:cmd,:name,:date_add,:from,:to,:price)");
$statementStmt->execute([
':registrar_id' => $clid,
':cmd' => 'create',

View file

@ -165,13 +165,7 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type, $trans) {
$to = $stmt->fetchColumn();
// Insert into statement:
if ($database_type === "mysql") {
$stmt = $db->prepare("INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, from, to, amount) VALUES (?, CURRENT_TIMESTAMP(3), ?, ?, ?, ?, ?, ?)");
} elseif ($database_type === "pgsql") {
$stmt = $db->prepare('INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, "from", "to", amount) VALUES (?, CURRENT_TIMESTAMP(3), ?, ?, ?, ?, ?, ?)');
} else {
throw new Exception("Unsupported database type: $database_type");
}
$stmt = $db->prepare("INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, fromS, toS, amount) VALUES (?, CURRENT_TIMESTAMP(3), ?, ?, ?, ?, ?, ?)");
$stmt->execute([$clid['id'], 'renew', $domainName, $date_add, $from, $to, $price]);
}
}

View file

@ -501,7 +501,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
$stmt->execute(['domain_id' => $domain_id]);
$to = $stmt->fetchColumn();
$stmt = $db->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,from,to,amount) VALUES(:registrar_id, CURRENT_TIMESTAMP(3), :command, :domain_name, :length_in_months, :from, :to, :amount)");
$stmt = $db->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,fromS,toS,amount) VALUES(:registrar_id, CURRENT_TIMESTAMP(3), :command, :domain_name, :length_in_months, :from, :to, :amount)");
$stmt->execute(['registrar_id' => $reid, 'command' => 'transfer', 'domain_name' => $domainName, 'length_in_months' => $date_add, 'from' => $from, 'to' => $to, 'amount' => $price]);
$stmt = $db->prepare("SELECT id,registrant,crdate,exdate,lastupdate,clid,crid,upid,trdate,trstatus,reid,redate,acid,acdate,transfer_exdate FROM domain WHERE name = :name LIMIT 1");

View file

@ -1692,7 +1692,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
$stmt->execute([$domain_id]);
$to = $stmt->fetchColumn();
$sth = $db->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,from,to,amount) VALUES(?,CURRENT_TIMESTAMP(3),?,?,?,?,?,?)");
$sth = $db->prepare("INSERT INTO statement (registrar_id,date,command,domain_name,length_in_months,fromS,toS,amount) VALUES(?,CURRENT_TIMESTAMP(3),?,?,?,?,?,?)");
$sth->execute([$clid, 'restore', $domainName, 0, $from, $from, $restore_price]);
$sth->execute([$clid, 'renew', $domainName, 12, $from, $to, $renew_price]);