-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLudoDBInterfaces.php
More file actions
148 lines (130 loc) · 3.57 KB
/
LudoDBInterfaces.php
File metadata and controls
148 lines (130 loc) · 3.57 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/**
* LudoDB interfaces
* User: Alf Magne
* Date: 31.01.13
* @package LudoDB
* @author Alf Magne Kalleland <post@dhtmlgoodies.com>
*/
/**
* Interface for LudoDB database connection adapters
* @package LudoDB
*/
interface LudoDBAdapter
{
/**
* Connect to database
* @return mixed
*/
public function connect();
/**
* Execute a query and return resource
* @param $sql
* @param array $params
* @return mixed
*/
public function query($sql, $params = array());
/**
* Execute query and return first row.
* @param $sql
* @param array $params
* @return mixed
*/
public function one($sql, $params = array());
/**
* Return number of rows for given SQL with given params (for prepared statements).
*
* Example
*
* <code>
* $count = LudoDB::getInstance()->countRows("select * from city where country=?", array("Norway"));
* </code>
*
* @param $sql
* @param array $params
* @return mixed
*/
public function countRows($sql, $params = array());
/**
* Return id of last inserted record
* @return string
*/
public function getInsertId();
/**
* Return next row in result set.
* @param $result
* @return array
*/
public function nextRow($result);
/**
* Return value of first column in first row of query.
* @param $sql
* @param array $params
* @return mixed
*/
public function getValue($sql, $params = array());
/**
* Escape string to be inserted into the database
* @param $string
* @return mixed
*/
public function escapeString($string);
/**
* Return table definition, column names and column types for a table.
* @param String $tableName
* @return array
*/
public function getTableDefinition($tableName);
}
/**
* Classes for request handlers has to implement the LudoDBService interface
*
* The class also needs to implement a static function called getValidServices
* which returns an array of valid services, example array('read','save','delete');
* Methods with these names also has to be implemented. "read", "save" and "delete"
* are already implemented for LudoDBModel.
* @package LudoDB
* @author Alf Magne Kalleland <post@dhtmlgoodies.com>
*/
interface LudoDBService
{
/**
* Returns true is passed arguments are acceptable for the constructor.
* @param String $service
* @param Array $arguments
* @return bool
*/
public function validateArguments($service, $arguments);
/**
* Validate data sent to service method
* @param string $service
* @param array $data
* @return bool
*/
public function validateServiceData($service, $data);
/**
* Return true to enable caching in LudoDBRequest handler for the read service.
* When true a serialized version of LudoDBModel::read will
* be stored in a caching table. When caching is enabled,
* you should also implement clearCache() to clear cache in
* case Data has been changed.
* @param string $service
* @return boolean
*/
public function shouldCache($service);
/**
* Return array with names of valid services
* @return array
*/
public function getValidServices();
/**
* Return on success message for given service
* @param String $service
* @return String
*/
public function getOnSuccessMessageFor($service);
}
interface LudoDBAuthenticator
{
public function authenticate($resource, $service, $arguments, $data);
}