-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
58 lines (44 loc) · 1.8 KB
/
README
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
ObjectStore is a flat file value-key pair database for PHP, inspired by MongoDB PHP class.
It is suitable to be used in simple CMS websites that does not require full-featured database.
Copyriht (C) 2011 "Daddycat" Tan Yin See -- [email protected]
Latest Source: http://github.com/yinsee/phpObjectStore
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------------------
1) How to use
<?
require("class.ObjectStore.php");
// $options is optional parameter
$options = array('gzip'=>9, 'autosave'=>true, 'dir'=>'/var/lib/phpobjstore/');
$db = new ObjectStore('name', $options);
...
...
?>
simple one db scenario
----------------------
Add / Insert:
$id = $db->insert(array $newdata);
Update:
$db->update($id, array $newdata);
Set / Replace:
$db->set($id, array $newdata);
Find:
$result = $db->find($id) or (array $search_keys);
* $search_keys supports PHP preg_search, eg: array($brand => new Regexp('/apple|dell/i'));
Delete:
$db->delete($id);
multiple tables scenario
------------------------
$id = $db->table->insert(array $newdata);
$db->table->update($id, array $newdata);
$db->table->set($id, array $newdata);
$result = $db->table->find($id) or (array $search_keys);
$db->table->delete($id);