forked from crodas/Bancard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_config.php
62 lines (51 loc) · 1.82 KB
/
demo_config.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
53
54
55
56
57
58
59
60
61
<?php
/**!
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <[email protected]> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Cesar Rodas.
* ----------------------------------------------------------------------------
*/
require "lib/Bancard.php";
/**
* Demostracion de como configurar Bancard con MySQL
*
*/
class Bancard_Config_Demo extends Bancard_Config
{
protected $link;
protected $tabla = 'foobar';
public function __construct()
{
$this->link = mysql_connect('localhost', 'root', 'password');
mysql_select_db('algo', $this->link);
}
public function getComercioId()
{
return 9343;
}
public function dbSave(array $data)
{
foreach ($data as $key => $value) {
$data[$key] = addslashes($value);
}
mysql_query("INSERT INTO `{$this->tabla}`(`moneda`, `monto`, `monto_orig`, `op`, `extra`) VALUES('{$data['moneda']}', '{$data['monto']}', '{$data['monto_orig']}', '{$data['op']}', '{$data['extra']}')", $this->link);
return mysql_insert_id();
}
public function dbConfirm($id, $transId, $nombre)
{
$id = (int)$id;
$transId = (int)$transId;
$nombre = addslashes($nombre);
mysql_query("UPDATE `{$this->tabla}` SET nombre='{$nombre}', confirmacion='{$transId}', cobrado=now() WHERE id = {$id}", $this->link);
}
public function dbGet($id)
{
$id = (int)$id;
$query = mysql_query("SELECT * FROM `{$this->tabla}` WHERE id = {$id}", $this->link);
$result = mysql_fetch_array($query);
mysql_free_result($query);
return $result;
}
}