diff --git a/tests/coverage/Doctrine.html b/tests/coverage/Doctrine.html index 4375b445e..56c22bc37 100644 --- a/tests/coverage/Doctrine.html +++ b/tests/coverage/Doctrine.html @@ -10,3171 +10,3561 @@
1 | -<?php + | <?php |
2 | -/* + | /* |
3 | -* $Id: Doctrine.php 3092 2007-11-08 19:01:22Z Jonathan.Wage $ + | * $Id: Doctrine.php 3223 2007-11-25 19:07:30Z romanb $ |
4 | -* + | * |
5 | -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
6 | -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
7 | -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
8 | -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
9 | -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
10 | -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
11 | -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
12 | -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
13 | -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
14 | -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
15 | -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
16 | -* + | * |
17 | -* This software consists of voluntary contributions made by many individuals + | * This software consists of voluntary contributions made by many individuals |
18 | -* and is licensed under the LGPL. For more information, see + | * and is licensed under the LGPL. For more information, see |
19 | -* <http://www.phpdoctrine.com>. + | * <http://www.phpdoctrine.com>. |
20 | -*/ + | */ |
21 | -+ | |
22 | -/** + | /** |
23 | -* Doctrine + | * Doctrine |
24 | -* the base class of Doctrine framework + | * the base class of Doctrine framework |
25 | -* + | * |
26 | -* @package Doctrine + | * @package Doctrine |
27 | -* @author Konsta Vesterinen <kvesteri@cc.hut.fi> + | * @author Konsta Vesterinen <kvesteri@cc.hut.fi> |
28 | -* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library) + | * @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library) |
29 | -* @license http://www.opensource.org/licenses/lgpl-license.php LGPL + | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL |
30 | -* @link www.phpdoctrine.com + | * @link www.phpdoctrine.com |
31 | -* @since 1.0 + | * @since 1.0 |
32 | -* @version $Revision: 3092 $ + | * @version $Revision: 3223 $ |
33 | -*/ + | */ |
34 | -final class Doctrine + | final class Doctrine |
35 | -{ + | { |
36 | -/** + | /** |
37 | -* VERSION + | * VERSION |
38 | -*/ + | */ |
39 | -const VERSION = '0.1.0'; + | const VERSION = '0.1.0'; |
40 | -+ | |
41 | -/** + | /** |
42 | -* ERROR CONSTANTS + | * ERROR CONSTANTS |
43 | -*/ + | */ |
44 | -const ERR = -1; + | const ERR = -1; |
45 | -const ERR_SYNTAX = -2; + | const ERR_SYNTAX = -2; |
46 | -const ERR_CONSTRAINT = -3; + | const ERR_CONSTRAINT = -3; |
47 | -const ERR_NOT_FOUND = -4; + | const ERR_NOT_FOUND = -4; |
48 | -const ERR_ALREADY_EXISTS = -5; + | const ERR_ALREADY_EXISTS = -5; |
49 | -const ERR_UNSUPPORTED = -6; + | const ERR_UNSUPPORTED = -6; |
50 | -const ERR_MISMATCH = -7; + | const ERR_MISMATCH = -7; |
51 | -const ERR_INVALID = -8; + | const ERR_INVALID = -8; |
52 | -const ERR_NOT_CAPABLE = -9; + | const ERR_NOT_CAPABLE = -9; |
53 | -const ERR_TRUNCATED = -10; + | const ERR_TRUNCATED = -10; |
54 | -const ERR_INVALID_NUMBER = -11; + | const ERR_INVALID_NUMBER = -11; |
55 | -const ERR_INVALID_DATE = -12; + | const ERR_INVALID_DATE = -12; |
56 | -const ERR_DIVZERO = -13; + | const ERR_DIVZERO = -13; |
57 | -const ERR_NODBSELECTED = -14; + | const ERR_NODBSELECTED = -14; |
58 | -const ERR_CANNOT_CREATE = -15; + | const ERR_CANNOT_CREATE = -15; |
59 | -const ERR_CANNOT_DELETE = -16; + | const ERR_CANNOT_DELETE = -16; |
60 | -const ERR_CANNOT_DROP = -17; + | const ERR_CANNOT_DROP = -17; |
61 | -const ERR_NOSUCHTABLE = -18; + | const ERR_NOSUCHTABLE = -18; |
62 | -const ERR_NOSUCHFIELD = -19; + | const ERR_NOSUCHFIELD = -19; |
63 | -const ERR_NEED_MORE_DATA = -20; + | const ERR_NEED_MORE_DATA = -20; |
64 | -const ERR_NOT_LOCKED = -21; + | const ERR_NOT_LOCKED = -21; |
65 | -const ERR_VALUE_COUNT_ON_ROW = -22; + | const ERR_VALUE_COUNT_ON_ROW = -22; |
66 | -const ERR_INVALID_DSN = -23; + | const ERR_INVALID_DSN = -23; |
67 | -const ERR_CONNECT_FAILED = -24; + | const ERR_CONNECT_FAILED = -24; |
68 | -const ERR_EXTENSION_NOT_FOUND = -25; + | const ERR_EXTENSION_NOT_FOUND = -25; |
69 | -const ERR_NOSUCHDB = -26; + | const ERR_NOSUCHDB = -26; |
70 | -const ERR_ACCESS_VIOLATION = -27; + | const ERR_ACCESS_VIOLATION = -27; |
71 | -const ERR_CANNOT_REPLACE = -28; + | const ERR_CANNOT_REPLACE = -28; |
72 | -const ERR_CONSTRAINT_NOT_NULL = -29; + | const ERR_CONSTRAINT_NOT_NULL = -29; |
73 | -const ERR_DEADLOCK = -30; + | const ERR_DEADLOCK = -30; |
74 | -const ERR_CANNOT_ALTER = -31; + | const ERR_CANNOT_ALTER = -31; |
75 | -const ERR_MANAGER = -32; + | const ERR_MANAGER = -32; |
76 | -const ERR_MANAGER_PARSE = -33; + | const ERR_MANAGER_PARSE = -33; |
77 | -const ERR_LOADMODULE = -34; + | const ERR_LOADMODULE = -34; |
78 | -const ERR_INSUFFICIENT_DATA = -35; + | const ERR_INSUFFICIENT_DATA = -35; |
79 | -const ERR_CLASS_NAME = -36; + | const ERR_CLASS_NAME = -36; |
80 | -+ | |
81 | -/** + | /** |
82 | -* PDO derived constants + | * PDO derived constants |
83 | -*/ + | */ |
84 | -const CASE_LOWER = 2; + | const CASE_LOWER = 2; |
85 | -const CASE_NATURAL = 0; + | const CASE_NATURAL = 0; |
86 | -const CASE_UPPER = 1; + | const CASE_UPPER = 1; |
87 | -const CURSOR_FWDONLY = 0; + | const CURSOR_FWDONLY = 0; |
88 | -const CURSOR_SCROLL = 1; + | const CURSOR_SCROLL = 1; |
89 | -const ERRMODE_EXCEPTION = 2; + | const ERRMODE_EXCEPTION = 2; |
90 | -const ERRMODE_SILENT = 0; + | const ERRMODE_SILENT = 0; |
91 | -const ERRMODE_WARNING = 1; + | const ERRMODE_WARNING = 1; |
92 | -const FETCH_ASSOC = 2; + | const FETCH_ASSOC = 2; |
93 | -const FETCH_BOTH = 4; + | const FETCH_BOTH = 4; |
94 | -const FETCH_BOUND = 6; + | const FETCH_BOUND = 6; |
95 | -const FETCH_CLASS = 8; + | const FETCH_CLASS = 8; |
96 | -const FETCH_CLASSTYPE = 262144; + | const FETCH_CLASSTYPE = 262144; |
97 | -const FETCH_COLUMN = 7; + | const FETCH_COLUMN = 7; |
98 | -const FETCH_FUNC = 10; + | const FETCH_FUNC = 10; |
99 | -const FETCH_GROUP = 65536; + | const FETCH_GROUP = 65536; |
100 | -const FETCH_INTO = 9; + | const FETCH_INTO = 9; |
101 | -const FETCH_LAZY = 1; + | const FETCH_LAZY = 1; |
102 | -const FETCH_NAMED = 11; + | const FETCH_NAMED = 11; |
103 | -const FETCH_NUM = 3; + | const FETCH_NUM = 3; |
104 | -const FETCH_OBJ = 5; + | const FETCH_OBJ = 5; |
105 | -const FETCH_ORI_ABS = 4; + | const FETCH_ORI_ABS = 4; |
106 | -const FETCH_ORI_FIRST = 2; + | const FETCH_ORI_FIRST = 2; |
107 | -const FETCH_ORI_LAST = 3; + | const FETCH_ORI_LAST = 3; |
108 | -const FETCH_ORI_NEXT = 0; + | const FETCH_ORI_NEXT = 0; |
109 | -const FETCH_ORI_PRIOR = 1; + | const FETCH_ORI_PRIOR = 1; |
110 | -const FETCH_ORI_REL = 5; + | const FETCH_ORI_REL = 5; |
111 | -const FETCH_SERIALIZE = 524288; + | const FETCH_SERIALIZE = 524288; |
112 | -const FETCH_UNIQUE = 196608; + | const FETCH_UNIQUE = 196608; |
113 | -const NULL_EMPTY_STRING = 1; + | const NULL_EMPTY_STRING = 1; |
114 | -const NULL_NATURAL = 0; + | const NULL_NATURAL = 0; |
115 | -const NULL_TO_STRING = NULL; + | const NULL_TO_STRING = NULL; |
116 | -const PARAM_BOOL = 5; + | const PARAM_BOOL = 5; |
117 | -const PARAM_INPUT_OUTPUT = -2147483648; + | const PARAM_INPUT_OUTPUT = -2147483648; |
118 | -const PARAM_INT = 1; + | const PARAM_INT = 1; |
119 | -const PARAM_LOB = 3; + | const PARAM_LOB = 3; |
120 | -const PARAM_NULL = 0; + | const PARAM_NULL = 0; |
121 | -const PARAM_STMT = 4; + | const PARAM_STMT = 4; |
122 | -const PARAM_STR = 2; + | const PARAM_STR = 2; |
123 | -+ | |
124 | -/** + | /** |
125 | -* ATTRIBUTE CONSTANTS + | * ATTRIBUTE CONSTANTS |
126 | -*/ + | */ |
127 | -+ | |
128 | -/** + | /** |
129 | -* PDO derived attributes + | * PDO derived attributes |
130 | -*/ + | */ |
131 | -const ATTR_AUTOCOMMIT = 0; + | const ATTR_AUTOCOMMIT = 0; |
132 | -const ATTR_PREFETCH = 1; + | const ATTR_PREFETCH = 1; |
133 | -const ATTR_TIMEOUT = 2; + | const ATTR_TIMEOUT = 2; |
134 | -const ATTR_ERRMODE = 3; + | const ATTR_ERRMODE = 3; |
135 | -const ATTR_SERVER_VERSION = 4; + | const ATTR_SERVER_VERSION = 4; |
136 | -const ATTR_CLIENT_VERSION = 5; + | const ATTR_CLIENT_VERSION = 5; |
137 | -const ATTR_SERVER_INFO = 6; + | const ATTR_SERVER_INFO = 6; |
138 | -const ATTR_CONNECTION_STATUS = 7; + | const ATTR_CONNECTION_STATUS = 7; |
139 | -const ATTR_CASE = 8; + | const ATTR_CASE = 8; |
140 | -const ATTR_CURSOR_NAME = 9; + | const ATTR_CURSOR_NAME = 9; |
141 | -const ATTR_CURSOR = 10; + | const ATTR_CURSOR = 10; |
142 | -const ATTR_ORACLE_NULLS = 11; + | const ATTR_ORACLE_NULLS = 11; |
143 | -const ATTR_PERSISTENT = 12; + | const ATTR_PERSISTENT = 12; |
144 | -const ATTR_STATEMENT_CLASS = 13; + | const ATTR_STATEMENT_CLASS = 13; |
145 | -const ATTR_FETCH_TABLE_NAMES = 14; + | const ATTR_FETCH_TABLE_NAMES = 14; |
146 | -const ATTR_FETCH_CATALOG_NAMES = 15; + | const ATTR_FETCH_CATALOG_NAMES = 15; |
147 | -const ATTR_DRIVER_NAME = 16; + | const ATTR_DRIVER_NAME = 16; |
148 | -const ATTR_STRINGIFY_FETCHES = 17; + | const ATTR_STRINGIFY_FETCHES = 17; |
149 | -const ATTR_MAX_COLUMN_LEN = 18; + | const ATTR_MAX_COLUMN_LEN = 18; |
150 | -+ | |
151 | -/** + | /** |
152 | -* Doctrine constants + | * Doctrine constants |
153 | -*/ + | */ |
154 | -const ATTR_LISTENER = 100; + | const ATTR_LISTENER = 100; |
155 | -const ATTR_QUOTE_IDENTIFIER = 101; + | const ATTR_QUOTE_IDENTIFIER = 101; |
156 | -const ATTR_FIELD_CASE = 102; + | const ATTR_FIELD_CASE = 102; |
157 | -const ATTR_IDXNAME_FORMAT = 103; + | const ATTR_IDXNAME_FORMAT = 103; |
158 | -const ATTR_SEQNAME_FORMAT = 104; + | const ATTR_SEQNAME_FORMAT = 104; |
159 | -const ATTR_SEQCOL_NAME = 105; + | const ATTR_SEQCOL_NAME = 105; |
160 | -const ATTR_CMPNAME_FORMAT = 118; + | const ATTR_CMPNAME_FORMAT = 118; |
161 | -const ATTR_DBNAME_FORMAT = 117; + | const ATTR_DBNAME_FORMAT = 117; |
162 | -const ATTR_TBLCLASS_FORMAT = 119; + | const ATTR_TBLCLASS_FORMAT = 119; |
163 | -const ATTR_TBLNAME_FORMAT = 120; + | const ATTR_TBLNAME_FORMAT = 120; |
164 | -const ATTR_EXPORT = 140; + | const ATTR_EXPORT = 140; |
165 | -const ATTR_DECIMAL_PLACES = 141; + | const ATTR_DECIMAL_PLACES = 141; |
166 | -+ | |
167 | -const ATTR_PORTABILITY = 106; + | const ATTR_PORTABILITY = 106; |
168 | -const ATTR_VALIDATE = 107; + | const ATTR_VALIDATE = 107; |
169 | -const ATTR_COLL_KEY = 108; + | const ATTR_COLL_KEY = 108; |
170 | -const ATTR_QUERY_LIMIT = 109; + | const ATTR_QUERY_LIMIT = 109; |
171 | -const ATTR_DEFAULT_TABLE_TYPE = 112; + | const ATTR_DEFAULT_TABLE_TYPE = 112; |
172 | -const ATTR_DEF_TEXT_LENGTH = 113; + | const ATTR_DEF_TEXT_LENGTH = 113; |
173 | -const ATTR_DEF_VARCHAR_LENGTH = 114; + | const ATTR_DEF_VARCHAR_LENGTH = 114; |
174 | -const ATTR_DEF_TABLESPACE = 115; + | const ATTR_DEF_TABLESPACE = 115; |
175 | -const ATTR_EMULATE_DATABASE = 116; + | const ATTR_EMULATE_DATABASE = 116; |
176 | -const ATTR_USE_NATIVE_ENUM = 117; + | const ATTR_USE_NATIVE_ENUM = 117; |
177 | -const ATTR_DEFAULT_SEQUENCE = 133; + | const ATTR_DEFAULT_SEQUENCE = 133; |
178 | -+ | |
179 | -const ATTR_FETCHMODE = 118; + | const ATTR_FETCHMODE = 118; |
180 | -const ATTR_NAME_PREFIX = 121; + | const ATTR_NAME_PREFIX = 121; |
181 | -const ATTR_CREATE_TABLES = 122; + | const ATTR_CREATE_TABLES = 122; |
182 | -const ATTR_COLL_LIMIT = 123; + | const ATTR_COLL_LIMIT = 123; |
183 | -+ | |
184 | -const ATTR_CACHE = 150; + | const ATTR_CACHE = 150; |
185 | -const ATTR_CACHE_LIFESPAN = 151; + | const ATTR_RESULT_CACHE = 150; |
186 | -const ATTR_LOAD_REFERENCES = 153; + | const ATTR_CACHE_LIFESPAN = 151; |
187 | -const ATTR_RECORD_LISTENER = 154; + | const ATTR_RESULT_CACHE_LIFESPAN = 151; |
188 | -const ATTR_THROW_EXCEPTIONS = 155; + | const ATTR_LOAD_REFERENCES = 153; |
189 | -const ATTR_DEFAULT_PARAM_NAMESPACE = 156; + | const ATTR_RECORD_LISTENER = 154; |
190 | -+ | const ATTR_THROW_EXCEPTIONS = 155; |
191 | -/** + | const ATTR_DEFAULT_PARAM_NAMESPACE = 156; |
192 | -* LIMIT CONSTANTS + | const ATTR_QUERY_CACHE = 157; |
193 | -*/ + | const ATTR_QUERY_CACHE_LIFESPAN = 158; |
194 | -+ | |
195 | -/** + | /** |
196 | -* constant for row limiting + | * LIMIT CONSTANTS |
197 | -*/ + | */ |
198 | -const LIMIT_ROWS = 1; + | |
199 | -+ | /** |
200 | -/** + | * constant for row limiting |
201 | -* constant for record limiting + | */ |
202 | -*/ + | const LIMIT_ROWS = 1; |
203 | -const LIMIT_RECORDS = 2; + | |
204 | -+ | /** |
205 | -/** + | * constant for record limiting |
206 | -* FETCHMODE CONSTANTS + | */ |
207 | -*/ + | const LIMIT_RECORDS = 2; |
208 | -+ | |
209 | -/** + | /** |
210 | -* IMMEDIATE FETCHING + | * FETCHMODE CONSTANTS |
211 | -* mode for immediate fetching + | */ |
212 | -*/ + | |
213 | -const FETCH_IMMEDIATE = 0; + | /** |
214 | -+ | * IMMEDIATE FETCHING |
215 | -/** + | * mode for immediate fetching |
216 | -* BATCH FETCHING + | */ |
217 | -* mode for batch fetching + | const FETCH_IMMEDIATE = 0; |
218 | -*/ + | |
219 | -const FETCH_BATCH = 1; + | /** |
220 | -+ | * BATCH FETCHING |
221 | -/** + | * mode for batch fetching |
222 | -* LAZY FETCHING + | */ |
223 | -* mode for offset fetching + | const FETCH_BATCH = 1; |
224 | -*/ + | |
225 | -const FETCH_OFFSET = 3; + | /** |
226 | -+ | * LAZY FETCHING |
227 | -/** + | * mode for offset fetching |
228 | -* LAZY OFFSET FETCHING + | */ |
229 | -* mode for lazy offset fetching + | const FETCH_OFFSET = 3; |
230 | -*/ + | |
231 | -const FETCH_LAZY_OFFSET = 4; + | /** |
232 | -+ | * LAZY OFFSET FETCHING |
233 | -/** + | * mode for lazy offset fetching |
234 | -* FETCH CONSTANTS + | */ |
235 | -*/ + | const FETCH_LAZY_OFFSET = 4; |
236 | -+ | |
237 | -+ | /** |
238 | -/** + | * FETCH CONSTANTS |
239 | -* FETCH VALUEHOLDER + | */ |
240 | -*/ + | |
241 | -const FETCH_VHOLDER = 1; + | |
242 | -+ | /** |
243 | -/** + | * FETCH VALUEHOLDER |
244 | -* FETCH RECORD + | */ |
245 | -* + | const FETCH_VHOLDER = 1; |
246 | -* Specifies that the fetch method shall return Doctrine_Record + | |
247 | -* objects as the elements of the result set. + | /** |
248 | -* + | * FETCH RECORD |
249 | -* This is the default fetchmode. + | * |
250 | -*/ + | * Specifies that the fetch method shall return Doctrine_Record |
251 | -const FETCH_RECORD = 2; + | * objects as the elements of the result set. |
252 | -+ | * |
253 | -/** + | * This is the default fetchmode. |
254 | -* FETCH ARRAY + | */ |
255 | -*/ + | const FETCH_RECORD = 2; |
256 | -const FETCH_ARRAY = 3; + | |
257 | -+ | /** |
258 | -/** + | * FETCH ARRAY |
259 | -* PORTABILITY CONSTANTS + | */ |
260 | -*/ + | const FETCH_ARRAY = 3; |
261 | -+ | |
262 | -/** + | /** |
263 | -* Portability: turn off all portability features. + | * PORTABILITY CONSTANTS |
264 | -* @see self::ATTR_PORTABILITY + | */ |
265 | -*/ + | |
266 | -const PORTABILITY_NONE = 0; + | /** |
267 | -+ | * Portability: turn off all portability features. |
268 | -/** + | * @see self::ATTR_PORTABILITY |
269 | -* Portability: convert names of tables and fields to case defined in the + | */ |
270 | -* "field_case" option when using the query*(), fetch*() methods. + | const PORTABILITY_NONE = 0; |
271 | -* @see self::ATTR_PORTABILITY + | |
272 | -*/ + | /** |
273 | -const PORTABILITY_FIX_CASE = 1; + | * Portability: convert names of tables and fields to case defined in the |
274 | -+ | * "field_case" option when using the query*(), fetch*() methods. |
275 | -/** + | * @see self::ATTR_PORTABILITY |
276 | -* Portability: right trim the data output by query*() and fetch*(). + | */ |
277 | -* @see self::ATTR_PORTABILITY + | const PORTABILITY_FIX_CASE = 1; |
278 | -*/ + | |
279 | -const PORTABILITY_RTRIM = 2; + | /** |
280 | -+ | * Portability: right trim the data output by query*() and fetch*(). |
281 | -/** + | * @see self::ATTR_PORTABILITY |
282 | -* Portability: force reporting the number of rows deleted. + | */ |
283 | -* @see self::ATTR_PORTABILITY + | const PORTABILITY_RTRIM = 2; |
284 | -*/ + | |
285 | -const PORTABILITY_DELETE_COUNT = 4; + | /** |
286 | -+ | * Portability: force reporting the number of rows deleted. |
287 | -/** + | * @see self::ATTR_PORTABILITY |
288 | -* Portability: convert empty values to null strings in data output by + | */ |
289 | -* query*() and fetch*(). + | const PORTABILITY_DELETE_COUNT = 4; |
290 | -* @see self::ATTR_PORTABILITY + | |
291 | -*/ + | /** |
292 | -const PORTABILITY_EMPTY_TO_NULL = 8; + | * Portability: convert empty values to null strings in data output by |
293 | -+ | * query*() and fetch*(). |
294 | -/** + | * @see self::ATTR_PORTABILITY |
295 | -* Portability: removes database/table qualifiers from associative indexes + | */ |
296 | -* @see self::ATTR_PORTABILITY + | const PORTABILITY_EMPTY_TO_NULL = 8; |
297 | -*/ + | |
298 | -const PORTABILITY_FIX_ASSOC_FIELD_NAMES = 16; + | /** |
299 | -+ | * Portability: removes database/table qualifiers from associative indexes |
300 | -/** + | * @see self::ATTR_PORTABILITY |
301 | -* Portability: makes Doctrine_Expression throw exception for unportable RDBMS expressions + | */ |
302 | -* @see self::ATTR_PORTABILITY + | const PORTABILITY_FIX_ASSOC_FIELD_NAMES = 16; |
303 | -*/ + | |
304 | -const PORTABILITY_EXPR = 32; + | /** |
305 | -+ | * Portability: makes Doctrine_Expression throw exception for unportable RDBMS expressions |
306 | -/** + | * @see self::ATTR_PORTABILITY |
307 | -* Portability: turn on all portability features. + | */ |
308 | -* @see self::ATTR_PORTABILITY + | const PORTABILITY_EXPR = 32; |
309 | -*/ + | |
310 | -const PORTABILITY_ALL = 63; + | /** |
311 | -+ | * Portability: turn on all portability features. |
312 | -/** + | * @see self::ATTR_PORTABILITY |
313 | -* LOCKMODE CONSTANTS + | */ |
314 | -*/ + | const PORTABILITY_ALL = 63; |
315 | -+ | |
316 | -/** + | /** |
317 | -* mode for optimistic locking + | * LOCKMODE CONSTANTS |
318 | -*/ + | */ |
319 | -const LOCK_OPTIMISTIC = 0; + | |
320 | -+ | /** |
321 | -/** + | * mode for optimistic locking |
322 | -* mode for pessimistic locking + | */ |
323 | -*/ + | const LOCK_OPTIMISTIC = 0; |
324 | -const LOCK_PESSIMISTIC = 1; + | |
325 | -+ | /** |
326 | -/** + | * mode for pessimistic locking |
327 | -* EXPORT CONSTANTS + | */ |
328 | -*/ + | const LOCK_PESSIMISTIC = 1; |
329 | -+ | |
330 | -/** + | /** |
331 | -* EXPORT_NONE + | * EXPORT CONSTANTS |
332 | -*/ + | */ |
333 | -const EXPORT_NONE = 0; + | |
334 | -+ | /** |
335 | -/** + | * EXPORT_NONE |
336 | -* EXPORT_TABLES + | */ |
337 | -*/ + | const EXPORT_NONE = 0; |
338 | -const EXPORT_TABLES = 1; + | |
339 | -+ | /** |
340 | -/** + | * EXPORT_TABLES |
341 | -* EXPORT_CONSTRAINTS + | */ |
342 | -*/ + | const EXPORT_TABLES = 1; |
343 | -const EXPORT_CONSTRAINTS = 2; + | |
344 | -+ | /** |
345 | -/** + | * EXPORT_CONSTRAINTS |
346 | -* EXPORT_PLUGINS + | */ |
347 | -*/ + | const EXPORT_CONSTRAINTS = 2; |
348 | -const EXPORT_PLUGINS = 4; + | |
349 | -+ | /** |
350 | -/** + | * EXPORT_PLUGINS |
351 | -* EXPORT_ALL + | */ |
352 | -*/ + | const EXPORT_PLUGINS = 4; |
353 | -const EXPORT_ALL = 7; + | |
354 | -+ | /** |
355 | -/** + | * EXPORT_ALL |
356 | -* HYDRATION CONSTANTS + | */ |
357 | -*/ + | const EXPORT_ALL = 7; |
358 | -const HYDRATE_RECORD = 2; + | |
359 | -+ | /** |
360 | -/** + | * HYDRATION CONSTANTS |
361 | -* HYDRATE_ARRAY + | */ |
362 | -*/ + | const HYDRATE_RECORD = 2; |
363 | -const HYDRATE_ARRAY = 3; + | |
364 | -+ | /** |
365 | -/** + | * HYDRATE_ARRAY |
366 | -* HYDRATE_NONE + | */ |
367 | -*/ + | const HYDRATE_ARRAY = 3; |
368 | -const HYDRATE_NONE = 4; + | |
369 | -+ | /** |
370 | -/** + | * HYDRATE_NONE |
371 | -* VALIDATION CONSTANTS + | */ |
372 | -*/ + | const HYDRATE_NONE = 4; |
373 | -const VALIDATE_NONE = 0; + | |
374 | -+ | /** |
375 | -/** + | * VALIDATION CONSTANTS |
376 | -* VALIDATE_LENGTHS + | */ |
377 | -*/ + | const VALIDATE_NONE = 0; |
378 | -const VALIDATE_LENGTHS = 1; + | |
379 | -+ | /** |
380 | -/** + | * VALIDATE_LENGTHS |
381 | -* VALIDATE_TYPES + | */ |
382 | -*/ + | const VALIDATE_LENGTHS = 1; |
383 | -const VALIDATE_TYPES = 2; + | |
384 | -+ | /** |
385 | -/** + | * VALIDATE_TYPES |
386 | -* VALIDATE_CONSTRAINTS + | */ |
387 | -*/ + | const VALIDATE_TYPES = 2; |
388 | -const VALIDATE_CONSTRAINTS = 4; + | |
389 | -+ | /** |
390 | -/** + | * VALIDATE_CONSTRAINTS |
391 | -* VALIDATE_ALL + | */ |
392 | -*/ + | const VALIDATE_CONSTRAINTS = 4; |
393 | -const VALIDATE_ALL = 7; + | |
394 | -+ | /** |
395 | -/** + | * VALIDATE_ALL |
396 | -* IDENTIFIER_AUTOINC + | */ |
397 | -* + | const VALIDATE_ALL = 7; |
398 | -* constant for auto_increment identifier + | |
399 | -*/ + | /** |
400 | -const IDENTIFIER_AUTOINC = 1; + | * IDENTIFIER_AUTOINC |
401 | -+ | * |
402 | -/** + | * constant for auto_increment identifier |
403 | -* IDENTIFIER_SEQUENCE + | */ |
404 | -* + | const IDENTIFIER_AUTOINC = 1; |
405 | -* constant for sequence identifier + | |
406 | -*/ + | /** |
407 | -const IDENTIFIER_SEQUENCE = 2; + | * IDENTIFIER_SEQUENCE |
408 | -+ | * |
409 | -/** + | * constant for sequence identifier |
410 | -* IDENTIFIER_NATURAL + | */ |
411 | -* + | const IDENTIFIER_SEQUENCE = 2; |
412 | -* constant for normal identifier + | |
413 | -*/ + | /** |
414 | -const IDENTIFIER_NATURAL = 3; + | * IDENTIFIER_NATURAL |
415 | -+ | * |
416 | -/** + | * constant for normal identifier |
417 | -* IDENTIFIER_COMPOSITE + | */ |
418 | -* + | const IDENTIFIER_NATURAL = 3; |
419 | -* constant for composite identifier + | |
420 | -*/ + | /** |
421 | -const IDENTIFIER_COMPOSITE = 4; + | * IDENTIFIER_COMPOSITE |
422 | -+ | * |
423 | -/** + | * constant for composite identifier |
424 | -* Path + | */ |
425 | -* + | const IDENTIFIER_COMPOSITE = 4; |
426 | -* @var string $path doctrine root directory + | |
427 | -*/ + | /** |
428 | -private static $_path; + | * Path |
429 | -+ | * |
430 | -/** + | * @var string $path doctrine root directory |
431 | -* Debug + | */ |
432 | -* + | private static $_path; |
433 | -* Bool true/false + | |
434 | -* + | /** |
435 | -* @var boolean $_debug + | * Debug |
436 | -*/ + | * |
437 | -private static $_debug = false; + | * Bool true/false |
438 | -+ | * |
439 | -/** + | * @var boolean $_debug |
440 | -* _loadedModels + | */ |
441 | -* + | private static $_debug = false; |
442 | -* Array of all the loaded models and the path to each one for autoloading + | |
443 | -* + | /** |
444 | -* @var string + | * _loadedModels |
445 | -*/ + | * |
446 | -private static $_loadedModels = array(); + | * Array of all the loaded models and the path to each one for autoloading |
447 | -+ | * |
448 | -/** + | * @var array |
449 | -* __construct + | */ |
450 | -* + | private static $_loadedModels = array(); |
451 | -* @return void + | |
452 | -* @throws Doctrine_Exception + | /** |
453 | -*/ + | * _validators |
454 | -public function __construct() + | * |
455 | -{ + | * Array of all the loaded validators |
456 | -throw new Doctrine_Exception('Doctrine is static class. No instances can be created.'); + | * @var array |
457 | -} + | */ |
458 | -+ | private static $_validators = array(); |
459 | -/** + | |
460 | -* debug + | /** |
461 | -* + | * Constructor for the main class |
462 | -* @param string $bool + | * |
463 | -* @return void + | * This class can not be instantiated so it will throw an exception. |
464 | -*/ + | * |
465 | -public static function debug($bool = null) + | * @return void |
466 | -{ + | * @throws Doctrine_Exception |
467 | -if ($bool !== null) { + | */ |
468 | -self::$_debug = (bool) $bool; + | public function __construct() |
469 | -} + | { |
470 | -+ | throw new Doctrine_Exception('Doctrine is static class. No instances can be created.'); |
471 | -return self::$_debug; + | } |
472 | -} + | |
473 | -+ | /** |
474 | -/** + | * debug |
475 | -* getPath + | * |
476 | -* returns the doctrine root + | * @param string $bool |
477 | -* + | * @return void |
478 | -* @return string + | */ |
479 | -*/ + | public static function debug($bool = null) |
480 | -public static function getPath() + | { |
481 | -{ + | if ($bool !== null) { |
482 | -if ( ! self::$_path) { + | self::$_debug = (bool) $bool; |
483 | -self::$_path = dirname(__FILE__); + | } |
484 | -} + | |
485 | -+ | return self::$_debug; |
486 | -return self::$_path; + | } |
487 | -} + | |
488 | -+ | /** |
489 | -/** + | * getPath |
490 | -* loadModels + | * returns the doctrine root |
491 | -* + | * |
492 | -* Recursively load all models from a directory or array of directories + | * @return string |
493 | -* + | */ |
494 | -* @param string $directory Path to directory of models or array of directory paths + | public static function getPath() |
495 | -* @return array $loadedModels + | { |
496 | -*/ + | if ( ! self::$_path) { |
497 | -public static function loadModels($directory) + | self::$_path = dirname(__FILE__); |
498 | -{ + | } |
499 | -if ($directory !== null) { + | |
500 | -$manager = Doctrine_Manager::getInstance(); + | return self::$_path; |
501 | -+ | } |
502 | -foreach ((array) $directory as $dir) { + | |
503 | -$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), + | /** |
504 | -RecursiveIteratorIterator::LEAVES_ONLY); + | * loadModels |
505 | -+ | * |
506 | -foreach ($it as $file) { + | * Recursively load all models from a directory or array of directories |
507 | -$e = explode('.', $file->getFileName()); + | * |
508 | -if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) { + | * @param string $directory Path to directory of models or array of directory paths |
509 | -self::$_loadedModels[$e[0]] = $file->getPathName(); + | * @return array $loadedModels |
510 | -} + | */ |
511 | -} + | public static function loadModels($directory) |
512 | -} + | { |
513 | -} + | if ($directory !== null) { |
514 | -+ | $manager = Doctrine_Manager::getInstance(); |
515 | -return self::getLoadedModels(array_keys(self::$_loadedModels)); + | |
516 | -} + | foreach ((array) $directory as $dir) { |
517 | -+ | $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), |
518 | -/** + | RecursiveIteratorIterator::LEAVES_ONLY); |
519 | -* getLoadedModels + | foreach ($it as $file) { |
520 | -* + | $e = explode('.', $file->getFileName()); |
521 | -* Get all the loaded models, you can provide an array of classes or it will use get_declared_classes() + | if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) { |
522 | -* + | self::$_loadedModels[$e[0]] = $file->getPathName(); |
523 | -* Will filter through an array of classes and return the Doctrine_Records out of them. + | } |
524 | -* If you do not specify $classes it will return all of the currently loaded Doctrine_Records + | } |
525 | -* + | } |
526 | -* @param $classes Array of classes to filter through, otherwise uses get_declared_classes() + | } |
527 | -* @return array $loadedModels + | |
528 | -*/ + | return self::getLoadedModels(array_keys(self::$_loadedModels)); |
529 | -public static function getLoadedModels($classes = null) + | } |
530 | -{ + | |
531 | -if ($classes === null) { + | /** |
532 | -$classes = get_declared_classes(); + | * getLoadedModels |
533 | -$classes = array_merge($classes, array_keys(self::$_loadedModels)); + | * |
534 | -} + | * Get all the loaded models, you can provide an array of classes or it will use get_declared_classes() |
535 | -+ | * |
536 | -$parent = new ReflectionClass('Doctrine_Record'); + | * Will filter through an array of classes and return the Doctrine_Records out of them. |
537 | -+ | * If you do not specify $classes it will return all of the currently loaded Doctrine_Records |
538 | -$loadedModels = array(); + | * |
539 | -+ | * @param classes Array of classes to filter through, otherwise uses get_declared_classes() |
540 | -foreach ((array) $classes as $name) { + | * @return array $loadedModels |
541 | -$class = new ReflectionClass($name); + | */ |
542 | -+ | public static function getLoadedModels($classes = null) |
543 | -// Skip the following classes + | { |
544 | -// - abstract classes + | if ($classes === null) { |
545 | -// - not a subclass of Doctrine_Record + | $classes = get_declared_classes(); |
546 | -// - don't have a setTableDefinition method + | $classes = array_merge($classes, array_keys(self::$_loadedModels)); |
547 | -if ($class->isAbstract() || + | } |
548 | -!$class->isSubClassOf($parent) || + | |
549 | -!$class->hasMethod('setTableDefinition')) { + | $loadedModels = array(); |
550 | -continue; + | |
551 | -} + | foreach ((array) $classes as $name) { |
552 | -+ | try { |
553 | -$loadedModels[] = $name; + | $declaredBefore = get_declared_classes(); |
554 | -} + | $class = new ReflectionClass($name); |
555 | -+ | if (self::isValidModelClass($class)) { |
556 | -return $loadedModels; + | $loadedModels[] = $name; |
557 | -} + | } |
558 | -+ | } catch (Exception $e) { |
559 | -/** + | // Determine class names by the actual inclusion of the model file |
560 | -* getConnectionByTableName + | // The possibility exists that the class name(s) contained in the model |
561 | -* + | // file is not the same as the actual model file name itself |
562 | -* Get the connection object for a table by the actual table name + | if (isset(self::$_loadedModels[$name])) { |
563 | -* + | try { |
564 | -* @param string $tableName + | require_once self::$_loadedModels[$name]; |
565 | -* @return object Doctrine_Connection + | $declaredAfter = get_declared_classes(); |
566 | -*/ + | // Using array_slice since array_diff is broken is some versions |
567 | -public static function getConnectionByTableName($tableName) + | $foundClasses = array_slice($declaredAfter, count($declaredBefore)-1); |
568 | -{ + | if ($foundClasses) { |
569 | -$loadedModels = self::getLoadedModels(); + | foreach ($foundClasses as $name) { |
570 | -+ | $class = new ReflectionClass($name); |
571 | -foreach ($loadedModels as $name) { + | if (self::isValidModelClass($class)) { |
572 | -$model = new $name(); + | $loadedModels[] = $name; |
573 | -$table = $model->getTable(); + | } |
574 | -+ | } |
575 | -if ($table->getTableName() == $tableName) { + | } |
576 | -return $table->getConnection(); + | } catch (Exception $e) { |
577 | -} + | continue; |
578 | -} + | } |
579 | -+ | } |
580 | -return Doctrine_Manager::connection(); + | } |
581 | -} + | |
582 | -+ | } |
583 | -/** + | return $loadedModels; |
584 | -* generateModelsFromDb + | } |
585 | -* + | |
586 | -* method for importing existing schema to Doctrine_Record classes + | |
587 | -* + | /** |
588 | -* @param string $directory Directory to write your models to + | * isValidModelClass |
589 | -* @param array $databases Array of databases to generate models for + | * |
590 | -* @return boolean + | * Checks whether a reflection class is a valid Doctrine model class |
591 | -* @throws Exception + | * |
592 | -*/ + | * @param class A reflection class to validate |
593 | -public static function generateModelsFromDb($directory, array $databases = array()) + | * @return boolean |
594 | -{ + | */ |
595 | -return Doctrine_Manager::connection()->import->importSchema($directory, $databases); + | public static function isValidModelClass($class) |
596 | -} + | { |
597 | -+ | if ($class instanceof ReflectionClass) { |
598 | -/** + | // Skip the following classes |
599 | -* generateYamlFromDb + | // - abstract classes |
600 | -* + | // - not a subclass of Doctrine_Record |
601 | -* Generates models from database to temporary location then uses those models to generate a yaml schema file. + | // - don't have a setTableDefinition method |
602 | -* This should probably be fixed. We should write something to generate a yaml schema file directly from the database. + | if (!$class->isAbstract() && |
603 | -* + | $class->isSubClassOf('Doctrine_Record') && |
604 | -* @param string $yamlPath Path to write oyur yaml schema file to + | $class->hasMethod('setTableDefinition')) { |
605 | -* @return void + | return true; |
606 | -*/ + | } |
607 | -public static function generateYamlFromDb($yamlPath) + | } |
608 | -{ + | return false; |
609 | -$directory = '/tmp/tmp_doctrine_models'; + | } |
610 | -+ | |
611 | -Doctrine::generateModelsFromDb($directory); + | |
612 | -+ | /** |
613 | -$export = new Doctrine_Export_Schema(); + | * getConnectionByTableName |
614 | -+ | * |
615 | -$result = $export->exportSchema($yamlPath, 'yml', $directory); + | * Get the connection object for a table by the actual table name |
616 | -+ | * |
617 | -exec('rm -rf ' . $directory); + | * @param string $tableName |
618 | -+ | * @return object Doctrine_Connection |
619 | -return $result; + | */ |
620 | -} + | public static function getConnectionByTableName($tableName) |
621 | -+ | { |
622 | -/** + | $loadedModels = self::getLoadedModels(); |
623 | -* generateModelsFromYaml + | |
624 | -* + | foreach ($loadedModels as $name) { |
625 | -* Generate a yaml schema file from an existing directory of models + | $model = new $name(); |
626 | -* + | $table = $model->getTable(); |
627 | -* @param string $yamlPath Path to your yaml schema files + | |
628 | -* @param string $directory Directory to generate your models in + | if ($table->getTableName() == $tableName) { |
629 | -* @param array $options Array of options to pass to the schema importer + | return $table->getConnection(); |
630 | -* @return void + | } |
631 | -*/ + | } |
632 | -public static function generateModelsFromYaml($yamlPath, $directory, $options = array()) + | |
633 | -{ + | return Doctrine_Manager::connection(); |
634 | -$import = new Doctrine_Import_Schema(); + | } |
635 | -$import->setOptions($options); + | |
636 | -+ | /** |
637 | -return $import->importSchema($yamlPath, 'yml', $directory); + | * generateModelsFromDb |
638 | -} + | * |
639 | -+ | * method for importing existing schema to Doctrine_Record classes |
640 | -/** + | * |
641 | -* createTablesFromModels + | * @param string $directory Directory to write your models to |
642 | -* + | * @param array $databases Array of databases to generate models for |
643 | -* Creates database tables for the models in the specified directory + | * @return boolean |
644 | -* + | * @throws Exception |
645 | -* @param string $directory Directory containing your models + | */ |
646 | -* @return void + | public static function generateModelsFromDb($directory, array $databases = array()) |
647 | -*/ + | { |
648 | -public static function createTablesFromModels($directory = null) + | return Doctrine_Manager::connection()->import->importSchema($directory, $databases); |
649 | -{ + | } |
650 | -return Doctrine_Manager::connection()->export->exportSchema($directory); + | |
651 | -} + | /** |
652 | -+ | * generateYamlFromDb |
653 | -/** + | * |
654 | -* createTablesFromArray + | * Generates models from database to temporary location then uses those models to generate a yaml schema file. |
655 | -* + | * This should probably be fixed. We should write something to generate a yaml schema file directly from the database. |
656 | -* Creates database tables for the models in the supplied array + | * |
657 | -* + | * @param string $yamlPath Path to write oyur yaml schema file to |
658 | -* @param array $array An array of models to be exported + | * @return void |
659 | -* @return void + | */ |
660 | -*/ + | public static function generateYamlFromDb($yamlPath) |
661 | -public static function createTablesFromArray($array) + | { |
662 | -{ + | $directory = '/tmp/tmp_doctrine_models'; |
663 | -return Doctrine_Manager::connection()->export->exportClasses($array); + | |
664 | -} + | Doctrine::generateModelsFromDb($directory); |
665 | -+ | |
666 | -/** + | $export = new Doctrine_Export_Schema(); |
667 | -* generateSqlFromModels + | |
668 | -* + | $result = $export->exportSchema($yamlPath, 'yml', $directory); |
669 | -* @param string $directory + | |
670 | -* @return string $build String of sql queries. One query per line + | exec('rm -rf ' . $directory); |
671 | -*/ + | |
672 | -public static function generateSqlFromModels($directory = null) + | return $result; |
673 | -{ + | } |
674 | -$sql = Doctrine_Manager::connection()->export->exportSql($directory); + | |
675 | -+ | /** |
676 | -$build = ''; + | * generateModelsFromYaml |
677 | -foreach ($sql as $query) { + | * |
678 | -$build .= $query.";\n"; + | * Generate a yaml schema file from an existing directory of models |
679 | -} + | * |
680 | -+ | * @param string $yamlPath Path to your yaml schema files |
681 | -return $build; + | * @param string $directory Directory to generate your models in |
682 | -} + | * @param array $options Array of options to pass to the schema importer |
683 | -+ | * @return void |
684 | -/** + | */ |
685 | -* generateYamlFromModels + | public static function generateModelsFromYaml($yamlPath, $directory, $options = array()) |
686 | -* + | { |
687 | -* Generate yaml schema file for the models in the specified directory + | $import = new Doctrine_Import_Schema(); |
688 | -* + | $import->setOptions($options); |
689 | -* @param string $yamlPath Path to your yaml schema files + | |
690 | -* @param string $directory Directory to generate your models in + | return $import->importSchema($yamlPath, 'yml', $directory); |
691 | -* @return void + | } |
692 | -*/ + | |
693 | -public static function generateYamlFromModels($yamlPath, $directory) + | /** |
694 | -{ + | * createTablesFromModels |
695 | -$export = new Doctrine_Export_Schema(); + | * |
696 | -+ | * Creates database tables for the models in the specified directory |
697 | -return $export->exportSchema($yamlPath, 'yml', $directory); + | * |
698 | -} + | * @param string $directory Directory containing your models |
699 | -+ | * @return void |
700 | -/** + | */ |
701 | -* createDatabases + | public static function createTablesFromModels($directory = null) |
702 | -* + | { |
703 | -* Creates databases for connections + | return Doctrine_Manager::connection()->export->exportSchema($directory); |
704 | -* + | } |
705 | -* @param string $specifiedConnections Array of connections you wish to create the database for + | |
706 | -* @return void + | /** |
707 | -*/ + | * createTablesFromArray |
708 | -public static function createDatabases($specifiedConnections = array()) + | * |
709 | -{ + | * Creates database tables for the models in the supplied array |
710 | -if ( ! is_array($specifiedConnections)) { + | * |
711 | -$specifiedConnections = (array) $specifiedConnections; + | * @param array $array An array of models to be exported |
712 | -} + | * @return void |
713 | -+ | */ |
714 | -$manager = Doctrine_Manager::getInstance(); + | public static function createTablesFromArray($array) |
715 | -$connections = $manager->getConnections(); + | { |
716 | -+ | return Doctrine_Manager::connection()->export->exportClasses($array); |
717 | -foreach ($connections as $name => $connection) { + | } |
718 | -if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { + | |
719 | -continue; + | /** |
720 | -} + | * generateSqlFromModels |
721 | -+ | * |
722 | -$info = $manager->parsePdoDsn($connection->getOption('dsn')); + | * @param string $directory |
723 | -$username = $connection->getOption('username'); + | * @return string $build String of sql queries. One query per line |
724 | -$password = $connection->getOption('password'); + | */ |
725 | -+ | public static function generateSqlFromModels($directory = null) |
726 | -// Make connection without database specified so we can create it + | { |
727 | -$connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false); + | $sql = Doctrine_Manager::connection()->export->exportSql($directory); |
728 | -+ | |
729 | -try { + | $build = ''; |
730 | -// Create database + | foreach ($sql as $query) { |
731 | -$connect->export->createDatabase($name); + | $build .= $query.";\n"; |
732 | -+ | } |
733 | -// Close the tmp connection with no database + | |
734 | -$manager->closeConnection($connect); + | return $build; |
735 | -+ | } |
736 | -// Close original connection + | |
737 | -$manager->closeConnection($connection); + | /** |
738 | -+ | * generateYamlFromModels |
739 | -// Reopen original connection with newly created database + | * |
740 | -$manager->openConnection(new PDO($info['dsn'], $username, $password), $name, true); + | * Generate yaml schema file for the models in the specified directory |
741 | -} catch (Exception $e) { + | * |
742 | -+ | * @param string $yamlPath Path to your yaml schema files |
743 | -} + | * @param string $directory Directory to generate your models in |
744 | -} + | * @return void |
745 | -} + | */ |
746 | -+ | public static function generateYamlFromModels($yamlPath, $directory) |
747 | -/** + | { |
748 | -* dropDatabases + | $export = new Doctrine_Export_Schema(); |
749 | -* + | |
750 | -* Drops databases for connections + | return $export->exportSchema($yamlPath, 'yml', $directory); |
751 | -* + | } |
752 | -* @param string $specifiedConnections Array of connections you wish to drop the database for + | |
753 | -* @return void + | /** |
754 | -*/ + | * createDatabases |
755 | -public static function dropDatabases($specifiedConnections = array()) + | * |
756 | -{ + | * Creates databases for connections |
757 | -if ( ! is_array($specifiedConnections)) { + | * |
758 | -$specifiedConnections = (array) $specifiedConnections; + | * @param string $specifiedConnections Array of connections you wish to create the database for |
759 | -} + | * @return void |
760 | -+ | */ |
761 | -$manager = Doctrine_Manager::getInstance(); + | public static function createDatabases($specifiedConnections = array()) |
762 | -+ | { |
763 | -$connections = $manager->getConnections(); + | if ( ! is_array($specifiedConnections)) { |
764 | -+ | $specifiedConnections = (array) $specifiedConnections; |
765 | -foreach ($connections as $name => $connection) { + | } |
766 | -if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { + | |
767 | -continue; + | $manager = Doctrine_Manager::getInstance(); |
768 | -} + | $connections = $manager->getConnections(); |
769 | -+ | |
770 | -try { + | $results = array(); |
771 | -$connection->export->dropDatabase($name); + | |
772 | -} catch (Exception $e) { + | foreach ($connections as $name => $connection) { |
773 | -+ | if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { |
774 | -} + | continue; |
775 | -} + | } |
776 | -} + | |
777 | -+ | $info = $manager->parsePdoDsn($connection->getOption('dsn')); |
778 | -/** + | $username = $connection->getOption('username'); |
779 | -* dumpData + | $password = $connection->getOption('password'); |
780 | -* + | |
781 | -* Dump data to a yaml fixtures file + | // Make connection without database specified so we can create it |
782 | -* + | $connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false); |
783 | -* @param string $yamlPath Path to write the yaml data fixtures to + | |
784 | -* @param string $individualFiles Whether or not to dump data to individual fixtures files + | try { |
785 | -* @return void + | // Create database |
786 | -*/ + | $connect->export->createDatabase($name); |
787 | -public static function dumpData($yamlPath, $individualFiles = false) + | |
788 | -{ + | // Close the tmp connection with no database |
789 | -$data = new Doctrine_Data(); + | $manager->closeConnection($connect); |
790 | -+ | |
791 | -return $data->exportData($yamlPath, 'yml', array(), $individualFiles); + | // Close original connection |
792 | -} + | $manager->closeConnection($connection); |
793 | -+ | |
794 | -/** + | // Reopen original connection with newly created database |
795 | -* loadData + | $manager->openConnection(new PDO($info['dsn'], $username, $password), $name, true); |
796 | -* + | |
797 | -* Load data from a yaml fixtures file. + | $results[$name] = true; |
798 | -* The output of dumpData can be fed to loadData + | } catch (Exception $e) { |
799 | -* + | $results[$name] = false; |
800 | -* @param string $yamlPath Path to your yaml data fixtures + | } |
801 | -* @param string $append Whether or not to append the data + | } |
802 | -* @return void + | |
803 | -*/ + | return $results; |
804 | -public static function loadData($yamlPath, $append = false) + | } |
805 | -{ + | |
806 | -$data = new Doctrine_Data(); + | /** |
807 | -+ | * dropDatabases |
808 | -if ( ! $append) { + | * |
809 | -$data->purge(); + | * Drops databases for connections |
810 | -} + | * |
811 | -+ | * @param string $specifiedConnections Array of connections you wish to drop the database for |
812 | -return $data->importData($yamlPath, 'yml'); + | * @return void |
813 | -} + | */ |
814 | -+ | public static function dropDatabases($specifiedConnections = array()) |
815 | -/** + | { |
816 | -* migrate + | if ( ! is_array($specifiedConnections)) { |
817 | -* + | $specifiedConnections = (array) $specifiedConnections; |
818 | -* Migrate database to specified $to version. Migrates from current to latest if you do not specify. + | } |
819 | -* + | |
820 | -* @param string $migrationsPath Path to migrations directory which contains your migration classes + | $manager = Doctrine_Manager::getInstance(); |
821 | -* @param string $to Version you wish to migrate to. + | |
822 | -* @return bool true + | $connections = $manager->getConnections(); |
823 | -* @throws new Doctrine_Migration_Exception + | |
824 | -*/ + | $results = array(); |
825 | -public static function migrate($migrationsPath, $to = null) + | |
826 | -{ + | foreach ($connections as $name => $connection) { |
827 | -$migration = new Doctrine_Migration($migrationsPath); + | if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { |
828 | -+ | continue; |
829 | -return $migration->migrate($to); + | } |
830 | -} + | |
831 | -+ | try { |
832 | -/** + | $connection->export->dropDatabase($name); |
833 | -* generateMigrationClass + | |
834 | -* + | $results[$name] = true; |
835 | -* Generate new migration class skeleton + | } catch (Exception $e) { |
836 | -* + | $results[$name] = false; |
837 | -* @param string $className Name of the Migration class to generate + | } |
838 | -* @param string $migrationsPath Path to directory which contains your migration classes + | } |
839 | -*/ + | |
840 | -public static function generateMigrationClass($className, $migrationsPath) + | return $results; |
841 | -{ + | } |
842 | -$builder = new Doctrine_Migration_Builder($migrationsPath); + | |
843 | -+ | /** |
844 | -return $builder->generateMigrationClass($className); + | * dumpData |
845 | -} + | * |
846 | -+ | * Dump data to a yaml fixtures file |
847 | -/** + | * |
848 | -* generateMigrationsFromDb + | * @param string $yamlPath Path to write the yaml data fixtures to |
849 | -* + | * @param string $individualFiles Whether or not to dump data to individual fixtures files |
850 | -* @param string $migrationsPath + | * @return void |
851 | -* @return void + | */ |
852 | -* @throws new Doctrine_Migration_Exception + | public static function dumpData($yamlPath, $individualFiles = false) |
853 | -*/ + | { |
854 | -public static function generateMigrationsFromDb($migrationsPath) + | $data = new Doctrine_Data(); |
855 | -{ + | |
856 | -$builder = new Doctrine_Migration_Builder($migrationsPath); + | return $data->exportData($yamlPath, 'yml', array(), $individualFiles); |
857 | -+ | } |
858 | -return $builder->generateMigrationsFromDb(); + | |
859 | -} + | /** |
860 | -+ | * loadData |
861 | -/** + | * |
862 | -* generateMigrationsFromModels + | * Load data from a yaml fixtures file. |
863 | -* + | * The output of dumpData can be fed to loadData |
864 | -* @param string $migrationsPath + | * |
865 | -* @param string $modelsPath + | * @param string $yamlPath Path to your yaml data fixtures |
866 | -* @return void + | * @param string $append Whether or not to append the data |
867 | -*/ + | * @return void |
868 | -public static function generateMigrationsFromModels($migrationsPath, $modelsPath = null) + | */ |
869 | -{ + | public static function loadData($yamlPath, $append = false) |
870 | -$builder = new Doctrine_Migration_Builder($migrationsPath); + | { |
871 | -+ | $data = new Doctrine_Data(); |
872 | -return $builder->generateMigrationsFromModels($modelsPath); + | |
873 | -} + | if ( ! $append) { |
874 | -+ | $data->purge(); |
875 | -/** + | } |
876 | -* getTable + | |
877 | -* + | return $data->importData($yamlPath, 'yml'); |
878 | -* @param string $tableName + | } |
879 | -* @return void + | |
880 | -*/ + | /** |
881 | -public static function getTable($tableName) + | * migrate |
882 | -{ + | * |
883 | -return Doctrine_Manager::table($tableName); + | * Migrate database to specified $to version. Migrates from current to latest if you do not specify. |
884 | -} + | * |
885 | -+ | * @param string $migrationsPath Path to migrations directory which contains your migration classes |
886 | -/** + | * @param string $to Version you wish to migrate to. |
887 | -* fileFinder + | * @return bool true |
888 | -* + | * @throws new Doctrine_Migration_Exception |
889 | -* @param string $type + | */ |
890 | -* @return void + | public static function migrate($migrationsPath, $to = null) |
891 | -*/ + | { |
892 | -public static function fileFinder($type) + | $migration = new Doctrine_Migration($migrationsPath); |
893 | -{ + | |
894 | -return Doctrine_FileFinder::type($type); + | return $migration->migrate($to); |
895 | -} + | } |
896 | -+ | |
897 | -/** + | /** |
898 | -* compile + | * generateMigrationClass |
899 | -* + | * |
900 | -* method for making a single file of most used doctrine runtime components + | * Generate new migration class skeleton |
901 | -* including the compiled file instead of multiple files (in worst + | * |
902 | -* cases dozens of files) can improve performance by an order of magnitude + | * @param string $className Name of the Migration class to generate |
903 | -* + | * @param string $migrationsPath Path to directory which contains your migration classes |
904 | -* @param string $target + | */ |
905 | -* @param array $includedDrivers + | public static function generateMigrationClass($className, $migrationsPath) |
906 | -* @throws Doctrine_Exception + | { |
907 | -* @return void + | $builder = new Doctrine_Migration_Builder($migrationsPath); |
908 | -*/ + | |
909 | -public static function compile($target = null, $includedDrivers = array()) + | return $builder->generateMigrationClass($className); |
910 | -{ + | } |
911 | -return Doctrine_Compiler::compile($target, $includedDrivers); + | |
912 | -} + | /** |
913 | -+ | * generateMigrationsFromDb |
914 | -/** + | * |
915 | -* autoload + | * @param string $migrationsPath |
916 | -* + | * @return void |
917 | -* simple autoload function + | * @throws new Doctrine_Migration_Exception |
918 | -* returns true if the class was loaded, otherwise false + | */ |
919 | -* + | public static function generateMigrationsFromDb($migrationsPath) |
920 | -* @param string $classname + | { |
921 | -* @return boolean + | $builder = new Doctrine_Migration_Builder($migrationsPath); |
922 | -*/ + | |
923 | -public static function autoload($className) + | return $builder->generateMigrationsFromDb(); |
924 | -{ + | } |
925 | -if (class_exists($className, false)) { + | |
926 | -return false; + | /** |
927 | -} + | * generateMigrationsFromModels |
928 | -+ | * |
929 | -if ( ! self::$_path) { + | * @param string $migrationsPath |
930 | -self::$_path = dirname(__FILE__); + | * @param string $modelsPath |
931 | -} + | * @return void |
932 | -+ | */ |
933 | -$class = self::$_path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; + | public static function generateMigrationsFromModels($migrationsPath, $modelsPath = null) |
934 | -+ | { |
935 | -if (file_exists($class)) { + | $builder = new Doctrine_Migration_Builder($migrationsPath); |
936 | -require_once($class); + | |
937 | -+ | return $builder->generateMigrationsFromModels($modelsPath); |
938 | -return true; + | } |
939 | -} + | |
940 | -+ | /** |
941 | -$loadedModels = self::$_loadedModels; + | * getTable |
942 | -+ | * |
943 | -if (isset($loadedModels[$className]) && file_exists($loadedModels[$className])) { + | * @param string $tableName |
944 | -require_once($loadedModels[$className]); + | * @return void |
945 | -+ | */ |
946 | -return true; + | public static function getTable($tableName) |
947 | -} + | { |
948 | -+ | return Doctrine_Manager::table($tableName); |
949 | -return false; + | } |
950 | -} + | |
951 | -+ | /** |
952 | -/** + | * fileFinder |
953 | -* dump + | * |
954 | -* + | * @param string $type |
955 | -* dumps a given variable + | * @return void |
956 | -* + | */ |
957 | -* @param mixed $var a variable of any type + | public static function fileFinder($type) |
958 | -* @param boolean $output whether to output the content + | { |
959 | -* @return void|string + | return Doctrine_FileFinder::type($type); |
960 | -*/ + | } |
961 | -public static function dump($var, $output = true) + | |
962 | -{ + | /** |
963 | -$ret = array(); + | * compile |
964 | -switch (gettype($var)) { + | * |
965 | -case 'array': + | * method for making a single file of most used doctrine runtime components |
966 | -$ret[] = 'Array('; + | * including the compiled file instead of multiple files (in worst |
967 | -foreach ($var as $k => $v) { + | * cases dozens of files) can improve performance by an order of magnitude |
968 | -$ret[] = $k . ' : ' . self::dump($v, false); + | * |
969 | -} + | * @param string $target |
970 | -$ret[] = ")"; + | * @param array $includedDrivers |
971 | -break; + | * @throws Doctrine_Exception |
972 | -case 'object': + | * @return void |
973 | -$ret[] = 'Object(' . get_class($var) . ')'; + | */ |
974 | -break; + | public static function compile($target = null, $includedDrivers = array()) |
975 | -default: + | { |
976 | -$ret[] = var_export($var, true); + | return Doctrine_Compiler::compile($target, $includedDrivers); |
977 | -} + | } |
978 | -if ($output) { + | |
979 | -print implode("\n", $ret); + | /** |
980 | -} + | * autoload |
981 | -return implode("\n", $ret); + | * |
982 | -} + | * simple autoload function |
983 | -+ | * returns true if the class was loaded, otherwise false |
984 | -/** + | * |
985 | -* tableize + | * @param string $classname |
986 | -* + | * @return boolean |
987 | -* returns table name from class name + | */ |
988 | -* + | public static function autoload($className) |
989 | -* @param string $classname + | { |
990 | -* @return string + | if (class_exists($className, false)) { |
991 | -*/ + | return false; |
992 | -public static function tableize($classname) + | } |
993 | -{ + | |
994 | -return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $classname)); + | if ( ! self::$_path) { |
995 | -} + | self::$_path = dirname(__FILE__); |
996 | -+ | } |
997 | -/** + | |
998 | -* classify + | $class = self::$_path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
999 | -* + | |
1000 | -* returns class name from table name + | if (file_exists($class)) { |
1001 | -* + | require_once($class); |
1002 | -* @param string $tablename + | |
1003 | -* @return string + | return true; |
1004 | -*/ + | } |
1005 | -public static function classify($tablename) + | |
1006 | -{ + | $loadedModels = self::$_loadedModels; |
1007 | -return preg_replace_callback('~(_?)(_)([\w])~', array("Doctrine", "classifyCallback"), ucfirst($tablename)); + | |
1008 | -} + | if (isset($loadedModels[$className]) && file_exists($loadedModels[$className])) { |
1009 | -+ | require_once($loadedModels[$className]); |
1010 | -/** + | |
1011 | -* classifyCallback + | return true; |
1012 | -* + | } |
1013 | -* Callback function to classify a classname properly. + | |
1014 | -* + | return false; |
1015 | -* @param array $matches An array of matches from a pcre_replace call + | } |
1016 | -* @return string A string with matches 1 and mathces 3 in upper case. + | |
1017 | -*/ + | /** |
1018 | -public static function classifyCallback($matches) + | * dump |
1019 | -{ + | * |
1020 | -return $matches[1] . strtoupper($matches[3]); + | * dumps a given variable |
1021 | -} + | * |
1022 | -+ | * @param mixed $var a variable of any type |
1023 | -/** + | * @param boolean $output whether to output the content |
1024 | -* isValidClassName + | * @param string $indent indention string |
1025 | -* + | * @return void|string |
1026 | -* checks for valid class name (uses camel case and underscores) + | */ |
1027 | -* + | public static function dump($var, $output = true, $indent = "") |
1028 | -* @param string $classname + | { |
1029 | -* @return boolean + | $ret = array(); |
1030 | -*/ + | switch (gettype($var)) { |
1031 | -public static function isValidClassname($classname) + | case 'array': |
1032 | -{ + | $ret[] = 'Array('; |
1033 | -if (preg_match('~(^[a-z])|(_[a-z])|([\W])|(_{2})~', $classname)) { + | $indent .= " "; |
1034 | -return false; + | foreach ($var as $k => $v) { |
1035 | -} + | |
1036 | -+ | $ret[] = $indent . $k . ' : ' . self::dump($v, false, $indent); |
1037 | -return true; + | } |
1038 | -} + | $indent = substr($indent,0, -4); |
1039 | -+ | $ret[] = $indent . ")"; |
1040 | -/** + | break; |
1041 | -* makeDirectories + | case 'object': |
1042 | -* + | $ret[] = 'Object(' . get_class($var) . ')'; |
1043 | -* Makes the directories for a path recursively + | break; |
1044 | -* + | default: |
1045 | -* @param string $path + | $ret[] = var_export($var, true); |
1046 | -* @return void + | } |
1047 | -*/ + | if ($output) { |
1048 | -public static function makeDirectories($path, $mode = 0777) + | print implode("\n", $ret); |
1049 | -{ + | } |
1050 | -if (is_dir($path) || is_file($path)) { + | return implode("\n", $ret); |
1051 | -return true; + | } |
1052 | -} + | |
1053 | -+ | /** |
1054 | -return mkdir($path, $mode, true); + | * tableize |
1055 | -} + | * |
1056 | -} + | * returns table name from class name + |
1057 | +* + | |
1058 | +* @param string $classname + | |
1059 | +* @return string + | |
1060 | +*/ + | |
1061 | +public static function tableize($classname) + | |
1062 | +{ + | |
1063 | +return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $classname)); + | |
1064 | +} + | |
1065 | ++ | |
1066 | +/** + | |
1067 | +* classify + | |
1068 | +* + | |
1069 | +* returns class name from table name + | |
1070 | +* + | |
1071 | +* @param string $tablename + | |
1072 | +* @return string + | |
1073 | +*/ + | |
1074 | +public static function classify($tablename) + | |
1075 | +{ + | |
1076 | +return preg_replace_callback('~(_?)(_)([\w])~', array("Doctrine", "classifyCallback"), ucfirst($tablename)); + | |
1077 | +} + | |
1078 | ++ | |
1079 | +/** + | |
1080 | +* classifyCallback + | |
1081 | +* + | |
1082 | +* Callback function to classify a classname properly. + | |
1083 | +* + | |
1084 | +* @param array $matches An array of matches from a pcre_replace call + | |
1085 | +* @return string A string with matches 1 and mathces 3 in upper case. + | |
1086 | +*/ + | |
1087 | +public static function classifyCallback($matches) + | |
1088 | +{ + | |
1089 | +return $matches[1] . strtoupper($matches[3]); + | |
1090 | +} + | |
1091 | ++ | |
1092 | +/** + | |
1093 | +* isValidClassName + | |
1094 | +* + | |
1095 | +* checks for valid class name (uses camel case and underscores) + | |
1096 | +* + | |
1097 | +* @param string $classname + | |
1098 | +* @return boolean + | |
1099 | +*/ + | |
1100 | +public static function isValidClassname($classname) + | |
1101 | +{ + | |
1102 | +if (preg_match('~(^[a-z])|(_[a-z])|([\W])|(_{2})~', $classname)) { + | |
1103 | +return false; + | |
1104 | +} + | |
1105 | ++ | |
1106 | +return true; + | |
1107 | +} + | |
1108 | ++ | |
1109 | +/** + | |
1110 | +* makeDirectories + | |
1111 | +* + | |
1112 | +* Makes the directories for a path recursively + | |
1113 | +* + | |
1114 | +* @param string $path + | |
1115 | +* @return void + | |
1116 | +*/ + | |
1117 | +public static function makeDirectories($path, $mode = 0777) + | |
1118 | +{ + | |
1119 | +if (!$path) { + | |
1120 | +return false; + | |
1121 | +} + | |
1122 | ++ | |
1123 | +if (is_dir($path) || is_file($path)) { + | |
1124 | +return true; + | |
1125 | +} + | |
1126 | ++ | |
1127 | +return mkdir($path, $mode, true); + | |
1128 | +} + | |
1129 | ++ | |
1130 | +/** + | |
1131 | +* removeDirectories + | |
1132 | +* + | |
1133 | +* @param string $folderPath + | |
1134 | +* @return void + | |
1135 | +*/ + | |
1136 | +public static function removeDirectories($folderPath) + | |
1137 | +{ + | |
1138 | +if ( ! is_dir($folderPath)) + | |
1139 | +{ + | |
1140 | +return false; + | |
1141 | +} + | |
1142 | ++ | |
1143 | +foreach (scandir($folderPath) as $value) + | |
1144 | +{ + | |
1145 | +if ($value != '.' && $value != '..') + | |
1146 | +{ + | |
1147 | +$value = $folderPath . "/" . $value; + | |
1148 | ++ | |
1149 | +if (is_dir($value)) { + | |
1150 | +self::removeDirectories($value); + | |
1151 | +} else if (is_file($value)) { + | |
1152 | +@unlink($value); + | |
1153 | +} + | |
1154 | +} + | |
1155 | +} + | |
1156 | ++ | |
1157 | +return rmdir ( $folderPath ); + | |
1158 | +} + | |
1159 | ++ | |
1160 | +/** + | |
1161 | +* getValidators + | |
1162 | +* + | |
1163 | +* Get available doctrine validators + | |
1164 | +* + | |
1165 | +* @return array $validators + | |
1166 | +*/ + | |
1167 | +public static function getValidators() + | |
1168 | +{ + | |
1169 | +if (empty(self::$_validators)) { + | |
1170 | +$dir = Doctrine::getPath() . DIRECTORY_SEPARATOR . 'Doctrine' . DIRECTORY_SEPARATOR . 'Validator'; + | |
1171 | ++ | |
1172 | +$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY); + | |
1173 | +foreach ($files as $file) { + | |
1174 | +$e = explode('.', $file->getFileName()); + | |
1175 | ++ | |
1176 | +if (end($e) == 'php') { + | |
1177 | +$name = strtolower($e[0]); + | |
1178 | ++ | |
1179 | +self::$_validators[$name] = $name; + | |
1180 | +} + | |
1181 | +} + | |
1182 | +} + | |
1183 | ++ | |
1184 | +return self::$_validators; + | |
1185 | +} + | |
1186 | +} |