These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace ByJG\AnyDataset\Database; |
||
4 | |||
5 | use ByJG\AnyDataset\Repository\DBDataset; |
||
6 | use DateTime; |
||
7 | |||
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 de proper SQL commands to concatenate these string; |
||
20 | * use: |
||
21 | * for ($i = 0, $numArgs = func_num_args(); $i < $numArgs ; $i++) |
||
22 | * to get all parameters received. |
||
23 | * @param string $s1 |
||
24 | * @param string $s2 |
||
25 | * @return string |
||
26 | */ |
||
27 | function concat($s1, $s2 = null) |
||
0 ignored issues
–
show
|
|||
28 | { |
||
29 | return ""; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Given a SQL returns it with the proper LIMIT or equivalent method included |
||
34 | * @param string $sql |
||
35 | * @param int $start |
||
36 | * @param int $qty |
||
37 | * @return string |
||
38 | */ |
||
39 | function limit($sql, $start, $qty) |
||
0 ignored issues
–
show
|
|||
40 | { |
||
41 | return $sql; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Given a SQL returns it with the proper TOP or equivalent method included |
||
46 | * @param string $sql |
||
47 | * @param int $qty |
||
48 | * @return string |
||
49 | */ |
||
50 | function top($sql, $qty) |
||
0 ignored issues
–
show
|
|||
51 | { |
||
52 | return $sql; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Return if the database provider have a top or similar function |
||
57 | * @return bool |
||
58 | */ |
||
59 | function hasTop() |
||
0 ignored issues
–
show
|
|||
60 | { |
||
61 | return false; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Return if the database provider have a limit function |
||
66 | * @return bool |
||
67 | */ |
||
68 | function hasLimit() |
||
0 ignored issues
–
show
|
|||
69 | { |
||
70 | return false; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Format date column in sql string given an input format that understands Y M D |
||
75 | * @param string $fmt |
||
76 | * @param bool|string $col |
||
77 | * @return string |
||
78 | * @example $db->getDbFunctions()->SQLDate("d/m/Y H:i", "dtcriacao") |
||
79 | */ |
||
80 | function sqlDate($fmt, $col = false) |
||
0 ignored issues
–
show
|
|||
81 | { |
||
82 | return ""; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Format a string date to a string database readable format. |
||
87 | * |
||
88 | * @param string $date |
||
89 | * @param string $dateFormat |
||
90 | * @return string |
||
91 | */ |
||
92 | function toDate($date, $dateFormat) |
||
0 ignored issues
–
show
|
|||
93 | { |
||
94 | $dateTime = DateTime::createFromFormat($dateFormat, $date); |
||
95 | return $dateTime->format(self::YMDH); |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Format a string database readable format to a string date in a free format. |
||
100 | * |
||
101 | * @param string $date |
||
102 | * @param string $dateFormat |
||
103 | * @return string |
||
104 | */ |
||
105 | function fromDate($date, $dateFormat) |
||
0 ignored issues
–
show
|
|||
106 | { |
||
107 | $dateTime = DateTime::createFromFormat(self::YMDH, $date); |
||
108 | return $dateTime->format($dateFormat); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * |
||
113 | * @param DBDataset $dbdataset |
||
114 | * @param string $sql |
||
115 | * @param array $param |
||
116 | * @param string $sequence |
||
117 | * @return int |
||
118 | */ |
||
119 | function executeAndGetInsertedId($dbdataset, $sql, $param, $sequence = null) |
||
0 ignored issues
–
show
|
|||
120 | { |
||
121 | $dbdataset->execSQL($sql, $param); |
||
122 | return -1; |
||
123 | } |
||
124 | } |
||
125 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.