Skip to content

Instantly share code, notes, and snippets.

@pipethedev
Created December 16, 2019 21:02
Show Gist options
  • Select an option

  • Save pipethedev/f77f021f343a2d399bbad8ef2b3818a5 to your computer and use it in GitHub Desktop.

Select an option

Save pipethedev/f77f021f343a2d399bbad8ef2b3818a5 to your computer and use it in GitHub Desktop.
<?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