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\Exception\NotImplementedException; |
||
6 | use ByJG\AnyDataset\Repository\DBDataset; |
||
7 | |||
8 | class DBSqliteFunctions extends DBBaseFunctions |
||
9 | { |
||
10 | |||
11 | function concat($s1, $s2 = null) |
||
0 ignored issues
–
show
|
|||
12 | { |
||
13 | return implode(func_get_args(), ' || '); |
||
14 | } |
||
15 | |||
16 | /** |
||
17 | * Given a SQL returns it with the proper LIMIT or equivalent method included |
||
18 | * @param string $sql |
||
19 | * @param int $start |
||
20 | * @param int $qty |
||
21 | * @return string |
||
22 | */ |
||
23 | View Code Duplication | function limit($sql, $start, $qty) |
|
0 ignored issues
–
show
|
|||
24 | { |
||
25 | if (strpos($sql, ' LIMIT ') === false) { |
||
26 | return $sql . " LIMIT $start, $qty "; |
||
27 | } |
||
28 | |||
29 | return $sql; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Given a SQL returns it with the proper TOP or equivalent method included |
||
34 | * @param string $sql |
||
35 | * @param int $qty |
||
36 | * @return string |
||
37 | */ |
||
38 | function top($sql, $qty) |
||
0 ignored issues
–
show
|
|||
39 | { |
||
40 | return $this->limit($sql, 0, $qty); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Return if the database provider have a top or similar function |
||
45 | * @return bool |
||
46 | */ |
||
47 | function hasTop() |
||
0 ignored issues
–
show
|
|||
48 | { |
||
49 | return true; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Return if the database provider have a limit function |
||
54 | * @return bool |
||
55 | */ |
||
56 | function hasLimit() |
||
0 ignored issues
–
show
|
|||
57 | { |
||
58 | return true; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Format date column in sql string given an input format that understands Y M D |
||
63 | * @param string $fmt |
||
64 | * @param string|bool $col |
||
65 | * @return string |
||
66 | * @throws NotImplementedException |
||
67 | * @example $db->getDbFunctions()->SQLDate("d/m/Y H:i", "dtcriacao") |
||
68 | */ |
||
69 | function sqlDate($fmt, $col = false) |
||
0 ignored issues
–
show
|
|||
70 | { |
||
71 | throw new NotImplementedException('Not implemented'); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Format a string date to a string database readable format. |
||
76 | * |
||
77 | * @param string $date |
||
78 | * @param string $dateFormat |
||
79 | * @return string |
||
80 | */ |
||
81 | function toDate($date, $dateFormat) |
||
0 ignored issues
–
show
|
|||
82 | { |
||
83 | return parent::toDate($date, $dateFormat); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Format a string database readable format to a string date in a free format. |
||
88 | * |
||
89 | * @param string $date |
||
90 | * @param string $dateFormat |
||
91 | * @return string |
||
92 | */ |
||
93 | function fromDate($date, $dateFormat) |
||
0 ignored issues
–
show
|
|||
94 | { |
||
95 | return parent::fromDate($date, $dateFormat); |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * |
||
100 | * @param DBDataset $dbdataset |
||
101 | * @param string $sql |
||
102 | * @param array $param |
||
103 | * @return int |
||
104 | */ |
||
105 | View Code Duplication | function executeAndGetInsertedId($dbdataset, $sql, $param) |
|
0 ignored issues
–
show
|
|||
106 | { |
||
107 | $id = parent::executeAndGetInsertedId($dbdataset, $sql, $param); |
||
108 | $it = $dbdataset->getIterator("SELECT last_insert_rowid() id"); |
||
109 | if ($it->hasNext()) { |
||
110 | $sr = $it->moveNext(); |
||
111 | $id = $sr->getField("id"); |
||
112 | } |
||
113 | |||
114 | return $id; |
||
115 | } |
||
116 | } |
||
117 |
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.