1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette\Database;
9:
10: use Nette;
11:
12:
13: /**
14: * Represents a single table row.
15: *
16: * @author David Grudl
17: * @author Jan Skrasek
18: */
19: class Row extends Nette\ArrayHash implements IRow
20: {
21:
22: /**
23: * Returns a item.
24: * @param mixed key or index
25: * @return mixed
26: */
27: public function offsetGet($key)
28: {
29: if (is_int($key)) {
30: $arr = array_slice((array) $this, $key, 1);
31: if (!$arr) {
32: trigger_error('Undefined offset: ' . __CLASS__ . "[$key]", E_USER_NOTICE);
33: }
34: return current($arr);
35: }
36: return $this->$key;
37: }
38:
39:
40: /**
41: * Checks if $key exists.
42: * @param mixed key or index
43: * @return bool
44: */
45: public function offsetExists($key)
46: {
47: if (is_int($key)) {
48: return (bool) current(array_slice((array) $this, $key, 1));
49: }
50: return parent::offsetExists($key);
51: }
52:
53: }
54: