Created
December 16, 2019 21:02
-
-
Save pipethedev/f77f021f343a2d399bbad8ef2b3818a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Transaction{ | |
| private $db; | |
| public function __construct(){ | |
| $this->db = new Database; | |
| } | |
| public function addTransaction($data){ | |
| $this->db->query('INSERT INTO transactions (id, customer_id, product, amount, currency, status) VALUES (:id, :customer_id, :product, :amount, :currency, :status)'); | |
| //Binding | |
| $this->db->bind(':id', $data['id']); | |
| $this->db->bind(':customer_id', $data['customer_id']); | |
| $this->db->bind(':product', $data['product']); | |
| $this->db->bind(':amount', $data['amount']); | |
| $this->db->bind(':currency', $data['currency']); | |
| $this->db->bind(':status', $data['status']); | |
| //Execution | |
| if($this->db->execute()){ | |
| return true; | |
| }else{ | |
| //return error if not insert | |
| return false; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment