-
Notifications
You must be signed in to change notification settings - Fork 0
/
Database.php
61 lines (49 loc) · 934 Bytes
/
Database.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
/**
* Created by PhpStorm.
* User: avariya
* Date: 8/10/15
* Time: 11:29 AM
*/
namespace WalDB;
class SimpleDB
{
protected $db;
public function __construct()
{
$this->db = array();
}
public function insert($val)
{
$this->db[] = $val;
end($this->db);
$key = key($this->db);
return $key;
}
public function update($pos, $val)
{
$this->db[$pos] = $val;
return true;
}
public function delete($pos)
{
$cou = count($this->db);
unset($this->db[$pos]);
if (count($this->db) < $cou) {
return true;
}
return false;
}
public function showAll()
{
print_r($this->db);
}
public function showPos($pos)
{
echo $this->db[$pos], PHP_EOL;
}
public function find($val)
{
return array_search($val, $this->db);
}
}