-
Notifications
You must be signed in to change notification settings - Fork 338
Expand file tree
/
Copy pathStatementsInterface.php
More file actions
127 lines (112 loc) · 3.48 KB
/
Copy pathStatementsInterface.php
File metadata and controls
127 lines (112 loc) · 3.48 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
<?php
declare(strict_types=1);
namespace daos;
/**
* Interface for class providing SQL helpers.
*/
interface StatementsInterface {
/**
* null first for order by clause
*
* @param string $column column to concat
* @param 'DESC'|'ASC' $order
*
* @return string full statement
*/
public static function nullFirst(string $column, string $order): string;
/**
* sum statement for boolean columns
*
* @param string $column column to concat
*
* @return string full statement
*/
public static function sumBool(string $column): string;
/**
* bool true statement
*
* @param string $column column to check for truth
*
* @return string full statement
*/
public static function isTrue(string $column): string;
/**
* bool false statement
*
* @param string $column column to check for false
*
* @return string full statement
*/
public static function isFalse(string $column): string;
/**
* Combine expressions using OR operator.
*
* @param string ...$exprs expressions to combine
*
* @return string combined expression
*/
public static function exprOr(string ...$exprs): string;
/**
* check if CSV column matches a value.
*
* @param string $column CSV column to check
* @param string $value value to search in CSV column
*
* @return string full statement
*/
public static function csvRowMatches(string $column, string $value): string;
/**
* check column against int list.
*
* @param string $column column to check
* @param int[] $ints of string or int values to match column against
*
* @return ?string full statement
*/
public static function intRowMatches(string $column, array $ints);
/**
* Return the statement required to update a datetime column to the current
* datetime.
*
* @return string full statement
*/
public static function rowTouch(string $column): string;
/**
* Convert boolean into a representation recognized by the database engine.
*
* @return string representation of boolean
*/
public static function bool(bool $bool): string;
/**
* Convert a date into a representation suitable for storage or comparison.
*
* @return string representation of datetime
*/
public static function datetime(\DateTimeImmutable $date): string;
/**
* Ensure row values have the appropriate PHP type. This assumes we are
* using buffered queries (sql results are in PHP memory);.
*
* @param array<array<mixed>> $rows array of associative array representing row results
* @param array<string, DatabaseInterface::PARAM_*> $expectedRowTypes associative array mapping columns to PDO types
*
* @return array<array<mixed>> of associative array representing row results having
* expected types
*/
public static function ensureRowTypes(array $rows, array $expectedRowTypes): array;
/**
* convert string array to string for storage in table row
*
* @param string[] $a
*/
public static function csvRow(array $a): string;
/**
* Match a value to a regular expression.
*
* @param string $value value to match
* @param string $regex regular expression
*
* @return string expression for matching
*/
public static function matchesRegex(string $value, string $regex): string;
}