Code (PHP) pasted on 2019-01-26, 19:52 Raw Source
- <?php
- CREATE TABLE IF NOT EXISTS account (
- name TEXT PRIMARY KEY
- );
- ");
- CREATE TABLE IF NOT EXISTS recipientpayer (
- name TEXT PRIMARY KEY
- );
- ");
- CREATE TABLE IF NOT EXISTS payment (
- hash TEXT,
- account INTEGER,
- recipientpayer INTEGER,
- subject TEXT,
- date NUMERIC,
- amount NUMERIC,
- type TEXT,
- FOREIGN KEY(account) REFERENCES account(ROWID) ON UPDATE CASCADE ON DELETE RESTRICT,
- FOREIGN KEY(recipientpayer) REFERENCES recipientpayer(ROWID) ON UPDATE CASCADE ON DELETE RESTRICT
- );
- CREATE INDEX IF NOT EXISTS idx_payment_hash ON payment(hash);
- CREATE INDEX IF NOT EXISTS idx_payment_amount ON payment(date, amount);
- CREATE INDEX IF NOT EXISTS idx_payment_subject ON payment(date, subject);
- ");
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- try {
- $stmt = $this->db->prepare("
- INSERT INTO payment (
- hash, account, recipientpayer, subject, date, amount, type
- ) VALUES (
- ?, ?, ?, ?, ?, ?, ?
- )
- ");
- $stmt->execute([
- $payment->getHash(),
- $this->getAccountID($payment->getAccount()),
- $this->getRecipientPayerID($payment->getRecipientPayer()),
- $payment->getAmount(),
- ]);
- return $this->getPaymentID($payment->getHash());
- } catch (PDOException $e) {
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////