Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 425 lines (378 sloc) 12.075 kB
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
1 <?php
2 /**
3 * Lithium: the most rad php framework
4 *
14de7bf @gwoo Happy 2012!
gwoo authored
5 * @copyright Copyright 2012, Union of RAD (http://union-of-rad.org)
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
6 * @license http://opensource.org/licenses/bsd-license.php The BSD License
7 */
8
9 namespace lithium\data\collection;
10
11 class RecordSet extends \lithium\data\Collection {
12
13 /**
14 * An array containing each record's unique key. This allows, for example, lookups of records
15 * with composite keys, i.e.:
16 *
17 * {{{
18 * $payment = $records[array('client_id' => 42, 'invoice_id' => 21)];
19 * }}}
20 *
21 * @var array
22 */
23 protected $_index = array();
24
25 /**
26 * The internal pointer to indicate which `Record` is the current record.
27 *
28 * @var integer
29 */
30 protected $_pointer = 0;
31
32 /**
33 * A 2D array of column-mapping information, where the top-level key is the fully-namespaced
34 * model name, and the sub-arrays are column names.
35 *
36 * @var array
37 */
38 protected $_columns = array();
39
40 /**
b51972c @nateabele Beginning refactoring of... stuff.
nateabele authored
41 * Initializes the record set and uses the database connection to get the column list contained
42 * in the query that created this object.
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
43 *
44 * @see lithium\data\collection\RecordSet::$_columns
079a0ef @jperras Fixing violations of coding standard.
jperras authored
45 * @return void
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
46 * @todo The part that uses _handle->schema() should be rewritten so that the column list
47 * is coming from the query object.
48 */
49 protected function _init() {
50 parent::_init();
51
b51972c @nateabele Beginning refactoring of... stuff.
nateabele authored
52 if ($this->_result) {
11a99df @nateabele Removing unneeded variable declaration in `\template\helper\Form::fie…
nateabele authored
53 $this->_columns = $this->_columnMap();
54 }
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
55 if ($this->_data && !$this->_index) {
56 $this->_index = array_keys($this->_data);
57 $this->_data = array_values($this->_data);
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
58 }
59 }
60
61 /**
62 * Checks to see if a record with the given index key is in the record set. If the record
63 * cannot be found, and not all records have been loaded into the set, it will continue loading
64 * records until either all available records have been loaded, or a matching key has been
65 * found.
66 *
079a0ef @jperras Fixing violations of coding standard.
jperras authored
67 * @see lithium\data\collection\RecordSet::offsetGet()
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
68 * @param mixed $offset The ID of the record to check for.
69 * @return boolean Returns true if the record's ID is found in the set, otherwise false.
70 */
71 public function offsetExists($offset) {
72 if (in_array($offset, $this->_index)) {
73 return true;
74 }
75 return parent::offsetExists($offset);
76 }
77
78 /**
79 * Gets a record from the record set using PHP's array syntax, i.e. `$records[5]`. Using loose
80 * typing, integer keys can be accessed using strings and vice-versa. For record sets with
81 * composite keys, records may be accessed using arrays as array keys. Note that the order of
82 * the keys in the array does not matter.
83 *
84 * Because record data in `RecordSet` is lazy-loaded from the database, new records are fetched
85 * until one with a matching key is found.
86 *
079a0ef @jperras Fixing violations of coding standard.
jperras authored
87 * @see lithium\data\collection\RecordSet::$_index
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
88 * @param mixed $offset The offset, or ID (index) of the record you wish to load. If
89 * `$offset` is `null`, all records are loaded into the record set, and
90 * `offsetGet` returns `null`.
91 * @return object Returns a `Record` object if a record is found with a key that matches the
92 * value of `$offset`, otheriwse returns `null`.
93 */
94 public function offsetGet($offset) {
196fb8a @nateabele Implementing data value casting at object-write time, refactoring res…
nateabele authored
95 if ($offset !== null && in_array($offset, $this->_index)) {
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
96 return $this->_data[array_search($offset, $this->_index)];
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
97 }
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
98 if ($this->closed()) {
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
99 return null;
100 }
101 $model = $this->_model;
102
103 while ($record = $this->_populate(null, $offset)) {
b08fa44 @Howard3 Closes #279.
Howard3 authored
104 $key = $model::key($record);
105 $keySet = $offset == $key || (!$key && in_array($offset, $this->_index));
106 if (!is_null($offset) && $keySet) {
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
107 return $record;
108 }
109 }
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
110 $this->close();
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
111 }
112
113 /**
114 * Assigns a value to the specified offset.
115 *
116 * @param integer $offset The offset to assign the value to.
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
117 * @param mixed $data The value to set.
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
118 * @return mixed The value which was set.
119 */
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
120 public function offsetSet($offset, $data) {
121 return $this->_populate($data, $offset);
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
122 }
123
124 /**
125 * Unsets an offset.
126 *
127 * @param string $offset The offset to unset.
128 * @return void
129 */
130 public function offsetUnset($offset) {
131 unset($this->_index[$index = array_search($offset, $this->_index)]);
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
132 unset($this->_data[$index]);
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
133 }
134
135 /**
136 * Reset the set's iterator and return the first record in the set.
137 * The next call of `current()` will get the first record in the set.
138 *
139 * @return object `Record`
140 */
141 public function rewind() {
142 $this->_pointer = 0;
143 reset($this->_index);
9ee1c2d @nateabele Refactoring data layer to support CRUD operations against MySQL. Misc…
nateabele authored
144
145 if ($record = parent::rewind()) {
146 return $record;
147 }
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
148 return empty($this->_data) ? null : $this->_data[$this->_pointer];
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
149 }
150
151 /**
152 * Returns the currently pointed to record in the set.
153 *
97c5e7c @Howard3 Doing a general QA and Docblock
Howard3 authored
154 * @return object `Record`
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
155 */
156 public function current() {
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
157 return $this->_data[$this->_pointer];
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
158 }
159
160 /**
161 * Returns the currently pointed to record's unique key.
162 *
079a0ef @jperras Fixing violations of coding standard.
jperras authored
163 * @param boolean $full If true, returns the complete key.
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
164 * @return mixed
165 */
11a99df @nateabele Removing unneeded variable declaration in `\template\helper\Form::fie…
nateabele authored
166 public function key($full = false) {
167 $key = $this->_index[$this->_pointer];
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
168 return (is_array($key) && !$full) ? reset($key) : $key;
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
169 }
170
171 /**
172 * Returns the next record in the set, and advances the object's internal pointer. If the end of
b51972c @nateabele Beginning refactoring of... stuff.
nateabele authored
173 * the set is reached, a new record will be fetched from the data source connection handle.
174 * If no more records can be fetched, returns `null`.
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
175 *
176 * @return object Returns the next record in the set, or `null`, if no more records are
177 * available.
178 */
179 public function next() {
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
180 $this->_valid = (next($this->_data) !== false && next($this->_index) !== false);
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
181
182 if (!$this->_valid) {
183 $this->_valid = !is_null($this->_populate());
184 }
185 $return = null;
de46874 @nateabele Fixing database integration issues. Updating `\util\Collection::invok…
nateabele authored
186
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
187 if ($this->_valid) {
9e9d8ee @nateabele Only increment internal `RecordSet` array pointer if number of record…
nateabele authored
188 if (count($this->_data) > 1) {
189 $this->_pointer++;
190 }
de46874 @nateabele Fixing database integration issues. Updating `\util\Collection::invok…
nateabele authored
191 $return = $this->current();
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
192 }
193 return $return;
194 }
195
196 /**
6856623 @Howard3 RecordSet
Howard3 authored
197 * Returns the previous record in the set, and moves the internal pointer back. A previously
198 * fetched record is returned. If bounds are reached, returns `null`.
199 *
200 * @return object Returns the previous record in the set, or `null`, if bounds are reached.
201 */
202 public function prev() {
203 $this->_valid = (prev($this->_data) !== false && prev($this->_index) !== false);
204
205 $return = null;
206
207 if ($this->_valid) {
208 $this->_pointer--;
209 $return = $this->current();
210 }
211 return $return;
212 }
213
214 /**
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
215 * Converts the data in the record set to a different format, i.e. an array.
216 *
217 * @param string $format
218 * @param array $options
219 * @return mixed
220 */
643accb @nateabele Updating data branch to 0.6.
nateabele authored
221 public function to($format, array $options = array()) {
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
222 $defaults = array('indexed' => true);
223 $options += $defaults;
224
225 $result = null;
226 $this->offsetGet(null);
227
228 switch ($format) {
229 case 'array':
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
230 $result = array_map(function($r) { return $r->to('array'); }, $this->_data);
b60fa67 @mackstar Syntax fixes
mackstar authored
231
3c2b893 @nateabele Improving cursor validity checks for classes which implement `Iterator`.
nateabele authored
232 if (!(is_scalar(current($this->_index)) && $options['indexed'])) {
233 break;
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
234 }
97c5e7c @Howard3 Doing a general QA and Docblock
Howard3 authored
235 $indexAndResult = ($this->_index && $result);
236 $result = $indexAndResult ? array_combine($this->_index, $result) : array();
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
237 break;
238 default:
239 $result = parent::to($format, $options);
240 break;
241 }
242 return $result;
243 }
244
245 /**
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
246 * Applies a callback to all data in the collection.
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
247 *
248 * Overriden to load any data that has not yet been loaded.
249 *
250 * @param callback $filter The filter to apply.
251 * @return object This collection instance.
252 */
253 public function each($filter) {
254 $this->offsetGet(null);
255 return parent::each($filter);
256 }
257
258 /**
6040cfe @daschl Collections: Lazy-Loading data with $this->offsetGet() on find(). Fix…
daschl authored
259 * Filters a copy of the items in the collection.
260 *
261 * Overridden to load any data that has not yet been loaded.
262 *
263 * @param callback $filter Callback to use for filtering.
264 * @param array $options The available options are:
265 * - `'collect'`: If `true`, the results will be returned wrapped
266 * in a new `Collection` object or subclass.
267 * @return mixed The filtered items. Will be an array unless `'collect'` is defined in the
268 * `$options` argument, then an instance of this class will be returned.
269 */
270 public function find($filter, array $options = array()) {
271 $this->offsetGet(null);
272 return parent::find($filter, $options);
273 }
274
275 /**
f583206 @nervetattoo Implements Collection::reduce
nervetattoo authored
276 * Reduce, or fold, a collection down to a single value
277 *
278 * Overriden to load any data that has not yet been loaded.
279 *
280 * @param callback $filter The filter to apply.
281 * @param mixed $initial Initial value
282 * @return mixed A single reduced value
283 */
284 public function reduce($filter, $initial = false) {
285 $this->offsetGet(null);
286 return parent::reduce($filter, $initial);
287 }
288
289 /**
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
290 * Applies a callback to a copy of all data in the collection
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
291 * and returns the result.
292 *
293 * Overriden to load any data that has not yet been loaded.
294 *
295 * @param callback $filter The filter to apply.
296 * @param array $options The available options are:
297 * - `'collect'`: If `true`, the results will be returned wrapped
298 * in a new `Collection` object or subclass.
c25e039 @Howard3 Cleaning up PHPDoc @return tags with multiple return types defined.
Howard3 authored
299 * @return object The filtered data.
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
300 */
643accb @nateabele Updating data branch to 0.6.
nateabele authored
301 public function map($filter, array $options = array()) {
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
302 $this->offsetGet(null);
303 return parent::map($filter, $options);
304 }
305
306 /**
307 * Lazy-loads records from a query using a reference to a database adapter and a query
308 * result resource.
309 *
b51972c @nateabele Beginning refactoring of... stuff.
nateabele authored
310 * @param array $data
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
311 * @param mixed $key
312 * @return array
313 */
b51972c @nateabele Beginning refactoring of... stuff.
nateabele authored
314 protected function _populate($data = null, $key = null) {
20d3736 @nateabele Refactoring collection and entity classes to use `cast()` method of t…
nateabele authored
315 if ($this->closed() && !$data || !($model = $this->_model)) {
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
316 return;
317 }
318
aeed15c @nateabele Moving database results handling to self-contained iterable result ob…
nateabele authored
319 if (!($data = $data ?: $this->_result->next())) {
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
320 return $this->close();
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
321 }
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
322 $record = is_object($data) ? $data : $this->_mapRecord($data);
323 $key = $model::key($record);
b51972c @nateabele Beginning refactoring of... stuff.
nateabele authored
324
97c5e7c @Howard3 Doing a general QA and Docblock
Howard3 authored
325 if (!$key) {
b08fa44 @Howard3 Closes #279.
Howard3 authored
326 $key = count($this->_data);
327 }
328
aeed15c @nateabele Moving database results handling to self-contained iterable result ob…
nateabele authored
329 if (is_array($key)) {
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
330 $key = count($key) === 1 ? reset($key) : $key;
331 }
332 if (in_array($key, $this->_index)) {
196fb8a @nateabele Implementing data value casting at object-write time, refactoring res…
nateabele authored
333 $index = array_search($key, $this->_index);
334 $this->_data[$index] = $record;
335 return $this->_data[$index];
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
336 }
244646c @nateabele Adding test for `\data\Source`. Refactoring classes in `\data` into "…
nateabele authored
337 $this->_data[] = $record;
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
338 $this->_index[] = $key;
11a99df @nateabele Removing unneeded variable declaration in `\template\helper\Form::fie…
nateabele authored
339 return $record;
340 }
341
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
342 protected function _mapRecord($data) {
6856623 @Howard3 RecordSet
Howard3 authored
343 $options = array('exists' => true);
344 $relationships = array();
7a3d59e @nateabele Refactoring record mapping in `\data\collection\RecordSet`.
nateabele authored
345 $primary = $this->_model;
346 $conn = $primary::connection();
6856623 @Howard3 RecordSet
Howard3 authored
347
3c2b893 @nateabele Improving cursor validity checks for classes which implement `Iterator`.
nateabele authored
348 if (!$this->_query) {
6856623 @Howard3 RecordSet
Howard3 authored
349 return $conn->item($primary, $data, $options + compact('relationships'));
350 }
351
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
352 $dataMap = array();
353 $relMap = $this->_query->relationships();
354 $main = null;
355
83fe839 @Howard3 Relations grab all the data rows that belongs to them only
Howard3 authored
356 do {
357 $offset = 0;
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
358
359 foreach ($this->_columns as $name => $fields) {
83fe839 @Howard3 Relations grab all the data rows that belongs to them only
Howard3 authored
360 $fieldCount = count($fields);
361 $record = array_combine($fields, array_slice($data, $offset, $fieldCount));
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
362 $offset += $fieldCount;
83fe839 @Howard3 Relations grab all the data rows that belongs to them only
Howard3 authored
363
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
364 if ($name === 0) {
365 if ($main && $main != $record) {
366 $this->_result->prev();
83fe839 @Howard3 Relations grab all the data rows that belongs to them only
Howard3 authored
367 break 2;
7a3d59e @nateabele Refactoring record mapping in `\data\collection\RecordSet`.
nateabele authored
368 }
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
369 $main = $record;
370 continue;
371 }
83fe839 @Howard3 Relations grab all the data rows that belongs to them only
Howard3 authored
372
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
373 if ($relMap[$name]['type'] != 'hasMany') {
374 $dataMap[$name] = $record;
375 continue;
7a3d59e @nateabele Refactoring record mapping in `\data\collection\RecordSet`.
nateabele authored
376 }
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
377 $dataMap[$name][] = $record;
83fe839 @Howard3 Relations grab all the data rows that belongs to them only
Howard3 authored
378 }
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
379 } while ($data = $this->_result->next());
83fe839 @Howard3 Relations grab all the data rows that belongs to them only
Howard3 authored
380
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
381 foreach ($dataMap as $name => $rel) {
382 $field = $relMap[$name]['fieldName'];
8b132d5 @Howard3 1: Moved mapping of relationships (in particular hasMany) from Source…
Howard3 authored
383 $relModel = $relMap[$name]['model'];
3c2b893 @nateabele Improving cursor validity checks for classes which implement `Iterator`.
nateabele authored
384
8b132d5 @Howard3 1: Moved mapping of relationships (in particular hasMany) from Source…
Howard3 authored
385 if ($relMap[$name]['type'] == 'hasMany') {
3c2b893 @nateabele Improving cursor validity checks for classes which implement `Iterator`.
nateabele authored
386 foreach ($rel as &$data) {
8b132d5 @Howard3 1: Moved mapping of relationships (in particular hasMany) from Source…
Howard3 authored
387 $data = $conn->item($relModel, $data, $options);
388 }
389 $opts = array('class' => 'set');
390 $relationships[$field] = $conn->item($relModel, $rel, $options + $opts);
3c2b893 @nateabele Improving cursor validity checks for classes which implement `Iterator`.
nateabele authored
391 continue;
8b132d5 @Howard3 1: Moved mapping of relationships (in particular hasMany) from Source…
Howard3 authored
392 }
3c2b893 @nateabele Improving cursor validity checks for classes which implement `Iterator`.
nateabele authored
393 $relationships[$field] = $conn->item($relModel, $rel, $options);
eb5624f @nateabele `RecordSet`s now iterate properly. Implemented `Result::prev()` so th…
nateabele authored
394 }
395 return $conn->item($primary, $main, $options + compact('relationships'));
7a3d59e @nateabele Refactoring record mapping in `\data\collection\RecordSet`.
nateabele authored
396 }
397
11a99df @nateabele Removing unneeded variable declaration in `\template\helper\Form::fie…
nateabele authored
398 protected function _columnMap() {
1a4a9d0 @nateabele Moving class constructor from `\data\collection\Document` to `\data\C…
nateabele authored
399 if ($this->_query && $map = $this->_query->map()) {
3b7d133 @Howard3 Adding fixes for 'count' under the new field mapping, and adding supp…
Howard3 authored
400 if (isset($map[$this->_query->alias()])) {
401 $map = array($map[$this->_query->alias()]) + $map;
402 unset($map[$this->_query->alias()]);
403 } else {
404 $map = array(array_shift($map)) + $map;
405 }
11a99df @nateabele Removing unneeded variable declaration in `\template\helper\Form::fie…
nateabele authored
406 return $map;
407 }
b51972c @nateabele Beginning refactoring of... stuff.
nateabele authored
408 if (!($model = $this->_model)) {
409 return array();
410 }
3d4458a @Howard3 Implementing new field management for databases
Howard3 authored
411 if (!is_object($this->_query) || !$this->_query->join()) {
d4828e8 @Howard3 Fixed column mapping for queries with no joins.
Howard3 authored
412 $map = $model::connection()->schema($this->_query, $this->_result, $this);
413 return array_values($map);
6bf36d9 MySQL Changes:
unknown authored
414 }
2c09acf RecordSet: Added management for relations (particularly hasMany), fix…
unknown authored
415
416 $model = $this->_model;
3d4458a @Howard3 Implementing new field management for databases
Howard3 authored
417 $map = $model::connection()->schema($this->_query, $this->_result, $this);
418 $map = array($map[$this->_query->alias()]) + $map;
419 unset($map[$this->_query->alias()]);
6bf36d9 MySQL Changes:
unknown authored
420
3d4458a @Howard3 Implementing new field management for databases
Howard3 authored
421 return $map;
a8d7f7b @nateabele Adding missing (moved) classes in `\data`, dropping rule from .gitign…
nateabele authored
422 }
423 }
424
425 ?>
Something went wrong with that request. Please try again.