15
15
* @ingroup DB
16
16
* @ingroup Module
17
17
**/
18
- abstract class /* ANSI's */ Dialect
19
- extends Singleton
20
- implements Instantiatable
21
- {
18
+ abstract class /* ANSI's */ Dialect {
22
19
const LITERAL_NULL = 'NULL ' ;
23
20
const LITERAL_TRUE = 'TRUE ' ;
24
21
const LITERAL_FALSE = 'FALSE ' ;
25
22
23
+ /**
24
+ * @var DB
25
+ */
26
+ protected $ db = null ;
27
+
26
28
abstract public function preAutoincrement (DBColumn $ column );
27
29
abstract public function postAutoincrement (DBColumn $ column );
28
30
29
31
abstract public function hasTruncate ();
30
32
abstract public function hasMultipleTruncate ();
31
33
abstract public function hasReturning ();
32
34
35
+ abstract public function quoteValue ($ value );
36
+
33
37
/**
34
- must be implemented too:
35
-
36
- public static function quoteValue($value);
38
+ * @deprecated remove after onPHP 1.2+
39
+ * @return LiteDialect
37
40
**/
41
+ public static function me ()
42
+ {
43
+ throw new UnimplementedFeatureException ('Deprecated: dialects not extends Singleton now ' );
44
+ }
38
45
39
- public static function quoteField ($ field )
46
+ public function quoteField ($ field )
40
47
{
41
- return self :: quoteTable ($ field );
48
+ return $ this -> quoteTable ($ field );
42
49
}
43
50
44
- public static function quoteTable ($ table )
51
+ public function quoteTable ($ table )
45
52
{
46
53
return '" ' .$ table .'" ' ;
47
54
}
@@ -67,6 +74,16 @@ public static function dropTableMode($cascade = false)
67
74
: ' RESTRICT ' ;
68
75
}
69
76
77
+ /**
78
+ * @param DB $db
79
+ * @return Dialect
80
+ */
81
+ public function setDB (DB $ db )
82
+ {
83
+ $ this ->db = $ db ;
84
+ return $ this ;
85
+ }
86
+
70
87
public function quoteBinary ($ data )
71
88
{
72
89
return $ this ->quoteValue ($ data );
@@ -159,5 +176,16 @@ public function quoteIpInRange($range, $ip)
159
176
{
160
177
throw new UnimplementedFeatureException ();
161
178
}
179
+
180
+ protected function getLink ()
181
+ {
182
+ if (!$ this ->db )
183
+ throw new WrongStateException ('Expected setted db ' );
184
+ if (!$ this ->db ->isConnected ()) {
185
+ $ this ->db ->connect ();
186
+ }
187
+
188
+ return $ this ->db ->getLink ();
189
+ }
162
190
}
163
191
?>
0 commit comments