[ADDED] Properly insert coin values
This commit is contained in:
parent
2f2b3f578c
commit
6ddca7466c
@ -16,8 +16,9 @@ class Transaction extends Base {
|
|||||||
* @return bool
|
* @return bool
|
||||||
**/
|
**/
|
||||||
public function addTransaction($account_id, $amount, $type='Credit', $block_id=NULL, $coin_address=NULL, $txid=NULL) {
|
public function addTransaction($account_id, $amount, $type='Credit', $block_id=NULL, $coin_address=NULL, $txid=NULL) {
|
||||||
|
$amount = number_format($amount, $this->setting->getValue('system_coin_precision', 12), '.', '');
|
||||||
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, amount, block_id, type, coin_address, txid) VALUES (?, ?, ?, ?, ?, ?)");
|
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, amount, block_id, type, coin_address, txid) VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
if ($this->checkStmt($stmt) && $stmt->bind_param("idisss", $account_id, $amount, $block_id, $type, $coin_address, $txid) && $stmt->execute()) {
|
if ($this->checkStmt($stmt) && $stmt->bind_param("isisss", $account_id, $amount, $block_id, $type, $coin_address, $txid) && $stmt->execute()) {
|
||||||
$this->insert_id = $stmt->insert_id;
|
$this->insert_id = $stmt->insert_id;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -473,6 +474,7 @@ class Transaction extends Base {
|
|||||||
$transaction = new Transaction();
|
$transaction = new Transaction();
|
||||||
$transaction->setMemcache($memcache);
|
$transaction->setMemcache($memcache);
|
||||||
$transaction->setNotification($notification);
|
$transaction->setNotification($notification);
|
||||||
|
$transaction->setSetting($setting);
|
||||||
$transaction->setDebug($debug);
|
$transaction->setDebug($debug);
|
||||||
$transaction->setMysql($mysqli);
|
$transaction->setMysql($mysqli);
|
||||||
$transaction->setConfig($config);
|
$transaction->setConfig($config);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||||
|
|
||||||
define('MPOS_VERSION', '0.0.4');
|
define('MPOS_VERSION', '0.0.4');
|
||||||
define('DB_VERSION', '0.0.11');
|
define('DB_VERSION', '0.0.12');
|
||||||
define('CONFIG_VERSION', '0.0.8');
|
define('CONFIG_VERSION', '0.0.8');
|
||||||
define('HASH_VERSION', 1);
|
define('HASH_VERSION', 1);
|
||||||
|
|
||||||
|
|||||||
@ -134,7 +134,7 @@ CREATE TABLE IF NOT EXISTS `settings` (
|
|||||||
UNIQUE KEY `setting` (`name`)
|
UNIQUE KEY `setting` (`name`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.11');
|
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.12');
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `shares` (
|
CREATE TABLE IF NOT EXISTS `shares` (
|
||||||
`id` bigint(30) NOT NULL AUTO_INCREMENT,
|
`id` bigint(30) NOT NULL AUTO_INCREMENT,
|
||||||
@ -216,7 +216,7 @@ CREATE TABLE IF NOT EXISTS `transactions` (
|
|||||||
`account_id` int(255) unsigned NOT NULL,
|
`account_id` int(255) unsigned NOT NULL,
|
||||||
`type` varchar(25) DEFAULT NULL,
|
`type` varchar(25) DEFAULT NULL,
|
||||||
`coin_address` varchar(255) DEFAULT NULL,
|
`coin_address` varchar(255) DEFAULT NULL,
|
||||||
`amount` double DEFAULT '0',
|
`amount` double(50,30) DEFAULT '0',
|
||||||
`block_id` int(255) DEFAULT NULL,
|
`block_id` int(255) DEFAULT NULL,
|
||||||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`txid` varchar(256) DEFAULT NULL,
|
`txid` varchar(256) DEFAULT NULL,
|
||||||
|
|||||||
30
upgrade/definitions/0.0.11_to_0.0.12.inc.php
Normal file
30
upgrade/definitions/0.0.11_to_0.0.12.inc.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
function run_0012() {
|
||||||
|
// Ugly but haven't found a better way
|
||||||
|
global $setting, $config, $user, $mysqli, $transaction;
|
||||||
|
|
||||||
|
// Version information
|
||||||
|
$db_version_old = '0.0.11'; // What version do we expect
|
||||||
|
$db_version_new = '0.0.12'; // What is the new version we wish to upgrade to
|
||||||
|
$db_version_now = $setting->getValue('DB_VERSION'); // Our actual version installed
|
||||||
|
|
||||||
|
// Upgrade specific variables
|
||||||
|
$aSql[] = "ALTER TABLE " . $transaction->getTableName() . " CHANGE `amount` `amount` DOUBLE(60,30) NULL DEFAULT '0'";
|
||||||
|
$aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '0.0.12' WHERE name = 'DB_VERSION'";
|
||||||
|
|
||||||
|
if ($db_version_now == $db_version_old && version_compare($db_version_now, DB_VERSION, '<')) {
|
||||||
|
// Run the upgrade
|
||||||
|
echo '- Starting database migration to version ' . $db_version_new . PHP_EOL;
|
||||||
|
foreach ($aSql as $sql) {
|
||||||
|
echo '- Preparing: ' . $sql . PHP_EOL;
|
||||||
|
$stmt = $mysqli->prepare($sql);
|
||||||
|
if ($stmt && $stmt->execute()) {
|
||||||
|
echo '- success' . PHP_EOL;
|
||||||
|
} else {
|
||||||
|
echo '- failed: ' . $mysqli->error . PHP_EOL;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user