1 | <?php |
||
8 | abstract class DbBaseFunctions implements DbFunctionsInterface |
||
9 | { |
||
10 | |||
11 | const DMY = "d-m-Y"; |
||
12 | const MDY = "m-d-Y"; |
||
13 | const YMD = "Y-m-d"; |
||
14 | const DMYH = "d-m-Y H:i:s"; |
||
15 | const MDYH = "m-d-Y H:i:s"; |
||
16 | const YMDH = "Y-m-d H:i:s"; |
||
17 | |||
18 | /** |
||
19 | * Given two or more string the system will return the string containing the proper |
||
20 | * SQL commands to concatenate these string; |
||
21 | * use: |
||
22 | * for ($i = 0, $numArgs = func_num_args(); $i < $numArgs ; $i++) |
||
23 | * to get all parameters received. |
||
24 | * |
||
25 | * @param string $str1 |
||
26 | * @param string|null $str2 |
||
27 | * @return string |
||
28 | */ |
||
29 | abstract public function concat($str1, $str2 = null); |
||
30 | |||
31 | /** |
||
32 | * Given a SQL returns it with the proper LIMIT or equivalent method included |
||
33 | * @param string $sql |
||
34 | * @param int $start |
||
35 | * @param int $qty |
||
36 | * @return string |
||
37 | */ |
||
38 | abstract public function limit($sql, $start, $qty = null); |
||
39 | |||
40 | /** |
||
41 | * Given a SQL returns it with the proper TOP or equivalent method included |
||
42 | * @param string $sql |
||
43 | * @param int $qty |
||
44 | * @return string |
||
45 | */ |
||
46 | abstract public function top($sql, $qty); |
||
47 | |||
48 | /** |
||
49 | * Return if the database provider have a top or similar function |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function hasTop() |
||
56 | |||
57 | /** |
||
58 | * Return if the database provider have a limit function |
||
59 | * @return bool |
||
60 | */ |
||
61 | public function hasLimit() |
||
65 | |||
66 | /** |
||
67 | * Format date column in sql string given an input format that understands Y M D |
||
68 | * |
||
69 | * @param string $format |
||
70 | * @param string|bool $column |
||
71 | * @return string |
||
72 | * @example $db->getDbFunctions()->SQLDate("d/m/Y H:i", "dtcriacao") |
||
73 | */ |
||
74 | abstract public function sqlDate($format, $column = null); |
||
75 | |||
76 | |||
77 | protected function prepareSqlDate($input, $pattern, $delimitString = "'") |
||
97 | |||
98 | /** |
||
99 | * Format a string date to a string database readable format. |
||
100 | * |
||
101 | * @param string $date |
||
102 | * @param string $dateFormat |
||
103 | * @return string |
||
104 | */ |
||
105 | public function toDate($date, $dateFormat) |
||
110 | |||
111 | /** |
||
112 | * Format a string database readable format to a string date in a free format. |
||
113 | * |
||
114 | * @param string $date |
||
115 | * @param string $dateFormat |
||
116 | * @return string |
||
117 | */ |
||
118 | public function fromDate($date, $dateFormat) |
||
123 | |||
124 | /** |
||
125 | * |
||
126 | * @param DBDataset $dbdataset |
||
127 | * @param string $sql |
||
128 | * @param array $param |
||
129 | * @return int |
||
130 | */ |
||
131 | public function executeAndGetInsertedId($dbdataset, $sql, $param) |
||
136 | } |
||
137 |