-
Notifications
You must be signed in to change notification settings - Fork 1
/
Trade.php
executable file
·52 lines (46 loc) · 1.27 KB
/
Trade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
include_once('dbConnect.php');
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of Trade
*
* @author Omega
*/
class Trade {
public $time_stamp;
public $buy_ref;
public $sell_ref;
public $price;
public $amount;
public $stock;
public function __construct($buy_ref, $sell_ref, $price, $amount, $stock){
$this->buy_ref = $buy_ref;
$this->sell_ref = $sell_ref;
$this->price = $price;
$this->amount = $amount;
$this->stock =$stock;
}
public function __destruct() {
;
}
public function insertTradeBook(){
$q = "INSERT INTO trade_book (`timestamp`, `buy_ref`, `sell_ref`, `price`, `amount`, `stock`)
values (NOW(), '$this->buy_ref', '$this->sell_ref', '$this->price', '$this->amount', '$this->stock')";
$query = mysql_query($q);
if($query){
return 1;
}
else echo mysql_error();
}
public function toString(){
return $this->buy_ref." ".$this->sell_ref." ".$this->price." ".$this->amount;
}
}
$trade = new Trade(2, 4, 100, 12);
$trade->insertTradeBook();
echo $trade->toString();
unset($trade);
?>