mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-14 08:37:00 +02:00
Per registrar currency now fully available
This commit is contained in:
parent
5711546f78
commit
a9e84a855e
20 changed files with 681 additions and 243 deletions
|
@ -373,18 +373,9 @@ function processDomainCheck($conn, $db, $xml, $trans, $clid) {
|
|||
// Calculate or retrieve fee for this command
|
||||
$returnValue = getDomainPrice($db, $domainName, $tld_id, $date_add, $commandName, $clid);
|
||||
$price = $returnValue['price'];
|
||||
|
||||
$sth = $db->prepare("
|
||||
SELECT price
|
||||
FROM domain_restore_price
|
||||
WHERE tldid = ?
|
||||
AND (registrar_id = ? OR registrar_id IS NULL)
|
||||
ORDER BY registrar_id DESC
|
||||
LIMIT 1
|
||||
");
|
||||
$sth->execute([$tld_id, $clid]);
|
||||
$restore_price = $sth->fetchColumn();
|
||||
|
||||
|
||||
$restore_price = getDomainRestorePrice($db, $tld_id, $clid, $currency);
|
||||
|
||||
if ($commandName == 'restore') {
|
||||
$feeResponses[] = [
|
||||
'command' => $commandName,
|
||||
|
|
|
@ -866,14 +866,15 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans, $m
|
|||
$clid = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$clid = $clid['id'];
|
||||
|
||||
$stmt = $db->prepare("SELECT accountBalance, creditLimit FROM registrar WHERE id = :registrar_id LIMIT 1");
|
||||
$stmt = $db->prepare("SELECT accountBalance, creditLimit, currency FROM registrar WHERE id = :registrar_id LIMIT 1");
|
||||
$stmt->bindParam(':registrar_id', $clid, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$registrar_balance = $result['accountBalance'];
|
||||
$creditLimit = $result['creditLimit'];
|
||||
$currency = $result['currency'];
|
||||
|
||||
$returnValue = getDomainPrice($db, $domainName, $tld_id, $date_add, 'create', $clid);
|
||||
$returnValue = getDomainPrice($db, $domainName, $tld_id, $date_add, 'create', $clid, $currency);
|
||||
$price = $returnValue['price'];
|
||||
|
||||
if (!$price) {
|
||||
|
|
|
@ -225,12 +225,13 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
|||
$renewPeriod = $result['renewPeriod'];
|
||||
$renewedDate = $result['renewedDate'];
|
||||
$transferPeriod = $result['transferPeriod'];
|
||||
|
||||
$stmt = $db->prepare("SELECT id FROM registrar WHERE clid = :clid LIMIT 1");
|
||||
|
||||
$stmt = $db->prepare("SELECT id, currency FROM registrar WHERE clid = :clid LIMIT 1");
|
||||
$stmt->bindParam(':clid', $clid, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$clid = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$clid = $clid['id'];
|
||||
$result2 = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$clid = $result2['id'];
|
||||
$currency = $result2['currency'];
|
||||
|
||||
if ($clid != $registrar_id_domain) {
|
||||
sendEppError($conn, $db, 2201, 'Domain belongs to another registrar', $clTRID, $trans);
|
||||
|
@ -307,7 +308,7 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
|||
$addPeriod_id = $stmt->fetchColumn();
|
||||
|
||||
if ($addPeriod_id) {
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $addPeriod, 'create', $clid);
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $addPeriod, 'create', $clid, $currency);
|
||||
$price = $returnValue['price'];
|
||||
|
||||
if (!isset($price)) {
|
||||
|
@ -365,7 +366,7 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
|||
$autoRenewPeriod_id = $stmt->fetchColumn();
|
||||
|
||||
if ($autoRenewPeriod_id) {
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $autoRenewPeriod, 'renew', $clid);
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $autoRenewPeriod, 'renew', $clid, $currency);
|
||||
$price = $returnValue['price'];
|
||||
|
||||
if (!isset($price)) {
|
||||
|
@ -388,7 +389,7 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
|||
$renewPeriod_id = $stmt->fetchColumn();
|
||||
|
||||
if ($renewPeriod_id) {
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $renewPeriod, 'renew', $clid);
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $renewPeriod, 'renew', $clid, $currency);
|
||||
$price = $returnValue['price'];
|
||||
|
||||
if (!isset($price)) {
|
||||
|
@ -413,7 +414,7 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
|||
if ($transferPeriod_id) {
|
||||
// Return money if a transfer was also a renew
|
||||
if ($transferPeriod > 0) {
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $transferPeriod, 'renew', $clid);
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $transferPeriod, 'renew', $clid, $currency);
|
||||
$price = $returnValue['price'];
|
||||
|
||||
if (!isset($price)) {
|
||||
|
|
|
@ -106,14 +106,15 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type, $trans) {
|
|||
}
|
||||
|
||||
// Check registrar account balance
|
||||
$stmt = $db->prepare("SELECT accountBalance, creditLimit FROM registrar WHERE id = :registrarId LIMIT 1");
|
||||
$stmt = $db->prepare("SELECT accountBalance, creditLimit, currency FROM registrar WHERE id = :registrarId LIMIT 1");
|
||||
$stmt->bindParam(':registrarId', $clid['id'], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$registrar_balance = $row['accountBalance'];
|
||||
$creditLimit = $row['creditLimit'];
|
||||
|
||||
$returnValue = getDomainPrice($db, $domainData['name'], $domainData['tldid'], $date_add, 'renew', $clid);
|
||||
$currency = $row['currency'];
|
||||
|
||||
$returnValue = getDomainPrice($db, $domainData['name'], $domainData['tldid'], $date_add, 'renew', $clid['id'], $currency);
|
||||
$price = $returnValue['price'];
|
||||
|
||||
if (($registrar_balance + $creditLimit) < $price) {
|
||||
|
|
|
@ -470,7 +470,12 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
|
|||
$stmt->execute([$domainName]);
|
||||
$date_add = $stmt->fetchColumn();
|
||||
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $date_add, 'transfer', $clid);
|
||||
$stmt = $db->prepare("SELECT currency FROM registrar WHERE id = :registrar_id LIMIT 1");
|
||||
$stmt->execute([':registrar_id' => $clid]);
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$currency = $result["currency"];
|
||||
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $date_add, 'transfer', $clid, $currency);
|
||||
$price = $returnValue['price'];
|
||||
|
||||
if (($registrar_balance + $creditLimit) < $price) {
|
||||
|
@ -1022,13 +1027,14 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
|
|||
return;
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("SELECT accountBalance, creditLimit FROM registrar WHERE id = :registrar_id LIMIT 1");
|
||||
$stmt = $db->prepare("SELECT accountBalance, creditLimit, currency FROM registrar WHERE id = :registrar_id LIMIT 1");
|
||||
$stmt->execute([':registrar_id' => $clid]);
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$registrar_balance = $result["accountBalance"];
|
||||
$creditLimit = $result["creditLimit"];
|
||||
$currency = $result["currency"];
|
||||
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $date_add, 'transfer', $clid);
|
||||
$returnValue = getDomainPrice($db, $domainName, $tldid, $date_add, 'transfer', $clid, $currency);
|
||||
$price = $returnValue['price'];
|
||||
|
||||
if (($registrar_balance + $creditLimit) < $price) {
|
||||
|
|
|
@ -1844,32 +1844,14 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
|
|||
$temp_id = $sth->fetchColumn();
|
||||
|
||||
if ($temp_id == 1) {
|
||||
$sth = $db->prepare("SELECT accountBalance,creditLimit FROM registrar WHERE id = ?");
|
||||
$sth = $db->prepare("SELECT accountBalance,creditLimit,currency FROM registrar WHERE id = ?");
|
||||
$sth->execute([$clid]);
|
||||
list($registrar_balance, $creditLimit) = $sth->fetch();
|
||||
list($registrar_balance, $creditLimit, $currency) = $sth->fetch();
|
||||
|
||||
$sth = $db->prepare("
|
||||
SELECT m12
|
||||
FROM domain_price
|
||||
WHERE tldid = ?
|
||||
AND command = 'renew'
|
||||
AND (registrar_id = ? OR registrar_id IS NULL)
|
||||
ORDER BY registrar_id DESC
|
||||
LIMIT 1
|
||||
");
|
||||
$sth->execute([$row['tldid'], $clid]);
|
||||
$renew_price = $sth->fetchColumn();
|
||||
$returnValue = getDomainPrice($db, $domainName, $row['tldid'], 12, 'renew', $clid, $currency);
|
||||
$renew_price = $returnValue['price'];
|
||||
|
||||
$sth = $db->prepare("
|
||||
SELECT price
|
||||
FROM domain_restore_price
|
||||
WHERE tldid = ?
|
||||
AND (registrar_id = ? OR registrar_id IS NULL)
|
||||
ORDER BY registrar_id DESC
|
||||
LIMIT 1
|
||||
");
|
||||
$sth->execute([$row['tldid'], $clid]);
|
||||
$restore_price = $sth->fetchColumn();
|
||||
$restore_price = getDomainRestorePrice($db, $row['tldid'], $clid, $currency);
|
||||
|
||||
if (($registrar_balance + $creditLimit) < ($renew_price + $restore_price)) {
|
||||
sendEppError($conn, $db, 2104, 'There is no money on the account for restore and renew', $clTRID, $trans);
|
||||
|
|
|
@ -12,6 +12,11 @@ use League\Flysystem\Local\LocalFilesystemAdapter;
|
|||
use League\Flysystem\Filesystem;
|
||||
use MatthiasMullie\Scrapbook\Adapters\Flysystem as ScrapbookFlysystem;
|
||||
use MatthiasMullie\Scrapbook\Psr6\Pool;
|
||||
use Money\Money;
|
||||
use Money\Currency;
|
||||
use Money\Converter;
|
||||
use Money\Currencies\ISOCurrencies;
|
||||
use Money\Exchange\FixedExchange;
|
||||
|
||||
/**
|
||||
* Sets up and returns a Logger instance.
|
||||
|
@ -602,76 +607,234 @@ function updatePermittedIPs($pool, $permittedIPsTable) {
|
|||
}
|
||||
}
|
||||
|
||||
function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create', $registrar_id = null) {
|
||||
// Check if the domain is a premium domain
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT c.category_price
|
||||
FROM premium_domain_pricing p
|
||||
JOIN premium_domain_categories c ON p.category_id = c.category_id
|
||||
WHERE p.domain_name = ? AND p.tld_id = ?
|
||||
");
|
||||
$stmt->execute([$domain_name, $tld_id]);
|
||||
if ($stmt->rowCount() > 0) {
|
||||
return ['type' => 'premium', 'price' => number_format((float)$stmt->fetch()['category_price'], 2, '.', '')];
|
||||
function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create', $registrar_id = null, $currency = 'USD') {
|
||||
$cacheKey = "domain_price_{$domain_name}_{$tld_id}_{$date_add}_{$command}_{$registrar_id}_{$currency}";
|
||||
|
||||
// Try fetching from cache
|
||||
if (function_exists('apcu_fetch')) {
|
||||
$cached = apcu_fetch($cacheKey);
|
||||
if ($cached !== false) {
|
||||
return $cached;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there is a promotion for the domain
|
||||
$exchangeRates = getExchangeRates();
|
||||
$baseCurrency = $exchangeRates['base_currency'] ?? 'USD';
|
||||
$exchangeRate = $exchangeRates['rates'][$currency] ?? 1.0;
|
||||
|
||||
// Check for premium pricing
|
||||
$premiumPrice = apcu_fetch("premium_price_{$domain_name}_{$tld_id}") ?: fetchSingleValue(
|
||||
$pdo,
|
||||
'SELECT c.category_price
|
||||
FROM premium_domain_pricing p
|
||||
JOIN premium_domain_categories c ON p.category_id = c.category_id
|
||||
WHERE p.domain_name = ? AND p.tld_id = ?',
|
||||
[$domain_name, $tld_id]
|
||||
);
|
||||
|
||||
if (!is_null($premiumPrice) && $premiumPrice !== false) {
|
||||
$money = convertMoney(new Money((int) ($premiumPrice * 100), new Currency($baseCurrency)), $exchangeRate, $currency);
|
||||
$result = ['type' => 'premium', 'price' => formatMoney($money)];
|
||||
|
||||
apcu_store($cacheKey, $result, 1800);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Check for active promotions
|
||||
$currentDate = date('Y-m-d');
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT discount_percentage, discount_amount
|
||||
FROM promotion_pricing
|
||||
WHERE tld_id = ?
|
||||
AND promo_type = 'full'
|
||||
AND status = 'active'
|
||||
AND start_date <= ?
|
||||
AND end_date >= ?
|
||||
");
|
||||
$stmt->execute([$tld_id, $currentDate, $currentDate]);
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$promo = $stmt->fetch();
|
||||
$discount = null;
|
||||
|
||||
// Determine discount based on percentage or amount
|
||||
if (!empty($promo['discount_percentage'])) {
|
||||
$discount = $promo['discount_percentage']; // Percentage discount
|
||||
} elseif (!empty($promo['discount_amount'])) {
|
||||
$discount = $promo['discount_amount']; // Fixed amount discount
|
||||
}
|
||||
} else {
|
||||
$discount = null;
|
||||
$promo = apcu_fetch("promo_{$tld_id}") ?: fetchSingleRow(
|
||||
$pdo,
|
||||
"SELECT discount_percentage, discount_amount
|
||||
FROM promotion_pricing
|
||||
WHERE tld_id = ?
|
||||
AND promo_type = 'full'
|
||||
AND status = 'active'
|
||||
AND start_date <= ?
|
||||
AND end_date >= ?",
|
||||
[$tld_id, $currentDate, $currentDate]
|
||||
);
|
||||
|
||||
if ($promo) {
|
||||
apcu_store("promo_{$tld_id}", $promo, 3600);
|
||||
}
|
||||
|
||||
// Get regular price for the specified period
|
||||
$priceColumn = "m" . $date_add;
|
||||
$sql = "
|
||||
SELECT $priceColumn
|
||||
FROM domain_price
|
||||
WHERE tldid = ?
|
||||
AND command = ?
|
||||
AND (registrar_id = ? OR registrar_id IS NULL)
|
||||
ORDER BY registrar_id DESC
|
||||
LIMIT 1
|
||||
";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$tld_id, $command, $registrar_id]);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$regularPrice = $stmt->fetch()[$priceColumn];
|
||||
// Get regular price from DB
|
||||
$priceColumn = "m" . (int) $date_add;
|
||||
$regularPrice = apcu_fetch("regular_price_{$tld_id}_{$command}_{$registrar_id}") ?: fetchSingleValue(
|
||||
$pdo,
|
||||
"SELECT $priceColumn
|
||||
FROM domain_price
|
||||
WHERE tldid = ? AND command = ?
|
||||
AND (registrar_id = ? OR registrar_id IS NULL)
|
||||
ORDER BY registrar_id DESC LIMIT 1",
|
||||
[$tld_id, $command, $registrar_id]
|
||||
);
|
||||
|
||||
if ($discount !== null) {
|
||||
if (isset($promo['discount_percentage'])) {
|
||||
$discountAmount = $regularPrice * ($promo['discount_percentage'] / 100);
|
||||
if (!is_null($regularPrice) && $regularPrice !== false) {
|
||||
apcu_store("regular_price_{$tld_id}_{$command}_{$registrar_id}", $regularPrice, 1800);
|
||||
|
||||
$finalPrice = $regularPrice * 100; // Convert DB float to cents
|
||||
if ($promo) {
|
||||
if (!empty($promo['discount_percentage'])) {
|
||||
$discountAmount = (int) ($finalPrice * ($promo['discount_percentage'] / 100));
|
||||
} else {
|
||||
$discountAmount = $discount;
|
||||
$discountAmount = (int) ($promo['discount_amount'] * 100);
|
||||
}
|
||||
$price = $regularPrice - $discountAmount;
|
||||
return ['type' => 'promotion', 'price' => number_format((float)$price, 2, '.', '')];
|
||||
$finalPrice = max(0, $finalPrice - $discountAmount);
|
||||
$type = 'promotion';
|
||||
} else {
|
||||
$type = 'regular';
|
||||
}
|
||||
|
||||
return ['type' => 'regular', 'price' => number_format((float)$regularPrice, 2, '.', '')];
|
||||
|
||||
$money = convertMoney(new Money($finalPrice, new Currency($baseCurrency)), $exchangeRate, $currency);
|
||||
$result = ['type' => $type, 'price' => formatMoney($money)];
|
||||
|
||||
apcu_store($cacheKey, $result, 1800);
|
||||
return $result;
|
||||
}
|
||||
|
||||
return ['type' => 'not_found', 'price' => 0];
|
||||
return ['type' => 'not_found', 'price' => formatMoney(new Money(0, new Currency($currency)))];
|
||||
}
|
||||
|
||||
function getDomainRestorePrice($pdo, $tld_id, $registrar_id = null, $currency = 'USD') {
|
||||
$cacheKey = "domain_restore_price_{$tld_id}_{$registrar_id}_{$currency}";
|
||||
|
||||
// Try fetching from cache
|
||||
if (function_exists('apcu_fetch')) {
|
||||
$cached = apcu_fetch($cacheKey);
|
||||
if ($cached !== false) {
|
||||
return $cached;
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch exchange rates
|
||||
$exchangeRates = getExchangeRates();
|
||||
$baseCurrency = $exchangeRates['base_currency'] ?? 'USD';
|
||||
$exchangeRate = $exchangeRates['rates'][$currency] ?? 1.0;
|
||||
|
||||
// Fetch restore price from DB
|
||||
$restorePrice = fetchSingleValue(
|
||||
$pdo,
|
||||
"SELECT price
|
||||
FROM domain_restore_price
|
||||
WHERE tldid = ?
|
||||
AND (registrar_id = ? OR registrar_id IS NULL)
|
||||
ORDER BY registrar_id DESC
|
||||
LIMIT 1",
|
||||
[$tld_id, $registrar_id]
|
||||
);
|
||||
|
||||
// If no restore price is found, return 0.00
|
||||
if (is_null($restorePrice) || $restorePrice === false) {
|
||||
return '0.00';
|
||||
}
|
||||
|
||||
// Convert to Money object for precision
|
||||
$money = convertMoney(new Money((int) ($restorePrice * 100), new Currency($baseCurrency)), $exchangeRate, $currency);
|
||||
|
||||
// Format and cache the result
|
||||
$formattedPrice = formatMoney($money);
|
||||
apcu_store($cacheKey, $formattedPrice, 1800); // Cache for 30 minutes
|
||||
|
||||
return $formattedPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load exchange rates from JSON file with APCu caching.
|
||||
*/
|
||||
function getExchangeRates() {
|
||||
$cacheKey = 'exchange_rates';
|
||||
|
||||
if (function_exists('apcu_fetch')) {
|
||||
$cached = apcu_fetch($cacheKey);
|
||||
if ($cached !== false) {
|
||||
return $cached;
|
||||
}
|
||||
}
|
||||
|
||||
$filePath = "/var/www/cp/resources/exchange_rates.json";
|
||||
$defaultRates = [
|
||||
'base_currency' => 'USD',
|
||||
'rates' => [
|
||||
'USD' => 1.0 // Ensure USD always exists
|
||||
],
|
||||
'last_updated' => date('c') // ISO 8601 timestamp
|
||||
];
|
||||
|
||||
if (!file_exists($filePath) || !is_readable($filePath)) {
|
||||
if (function_exists('apcu_store')) {
|
||||
apcu_store($cacheKey, $defaultRates, 3600);
|
||||
}
|
||||
return $defaultRates;
|
||||
}
|
||||
|
||||
$json = file_get_contents($filePath);
|
||||
$data = json_decode($json, true);
|
||||
|
||||
if (!isset($data['base_currency'], $data['rates']) || !is_array($data['rates'])) {
|
||||
if (function_exists('apcu_store')) {
|
||||
apcu_store($cacheKey, $defaultRates, 3600);
|
||||
}
|
||||
return $defaultRates;
|
||||
}
|
||||
|
||||
// Ensure base currency exists
|
||||
if (!isset($data['rates'][$data['base_currency']])) {
|
||||
$data['rates'][$data['base_currency']] = 1.0;
|
||||
}
|
||||
|
||||
// Ensure every currency defaults to 1.0 if missing
|
||||
foreach ($data['rates'] as $currency => $rate) {
|
||||
if (!is_numeric($rate)) {
|
||||
$data['rates'][$currency] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (function_exists('apcu_store')) {
|
||||
apcu_store($cacheKey, $data, 3600);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert MoneyPHP object to the target currency.
|
||||
*/
|
||||
function convertMoney(Money $amount, float $exchangeRate, string $currency) {
|
||||
$currencies = new ISOCurrencies();
|
||||
$exchange = new FixedExchange([
|
||||
$amount->getCurrency()->getCode() => [
|
||||
$currency => (string) $exchangeRate // Convert float to string
|
||||
]
|
||||
]);
|
||||
$converter = new Converter($currencies, $exchange);
|
||||
|
||||
return $converter->convert($amount, new Currency($currency));
|
||||
}
|
||||
|
||||
/**
|
||||
* Format Money object back to a string (e.g., "10.00").
|
||||
*/
|
||||
function formatMoney(Money $money) {
|
||||
return number_format($money->getAmount() / 100, 2, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a single value from the database using PDO.
|
||||
*/
|
||||
function fetchSingleValue($pdo, string $query, array $params) {
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute($params);
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a single row from the database using PDO.
|
||||
*/
|
||||
function fetchSingleRow($pdo, string $query, array $params) {
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute($params);
|
||||
return $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
function generateAuthInfo(): string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue