1: <?php
2: /**
3: * ManiaLive - TrackMania dedicated server manager in PHP
4: *
5: * @copyright Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
6: * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
7: * @version $Revision: 440 $:
8: * @author $Author: martin.gwendal $:
9: * @date $Date: 2012-08-17 12:03:09 +0200 (ven., 17 août 2012) $:
10: */
11:
12: namespace ManiaLive\Database;
13:
14: abstract class RecordSet
15: {
16: abstract function __construct($result);
17:
18: /**
19: * @deprecated use fetchSingleValue instead
20: */
21: function fetchScalar()
22: {
23: return $this->fetchSingleValue();
24: }
25:
26: function fetchSingleValue($default = 0)
27: {
28: $row = $this->fetchRow();
29: return $row ? reset($row) : $default;
30: }
31:
32: function fetchArrayOfSingleValues()
33: {
34: $array = array();
35: while($row = $this->fetchRow())
36: {
37: $array[] = reset($row);
38: }
39: return $array;
40: }
41:
42: /**
43: * Get a result row as an enumerated array
44: * Returns an numerical array of strings that corresponds to the fetched row
45: * @return array
46: */
47: abstract function fetchRow();
48:
49: function fetchArrayOfRow()
50: {
51: $array = array();
52: while($row = $this->fetchRow())
53: {
54: $array[] = $row;
55: }
56: return $array;
57: }
58:
59: /**
60: * Fetch a result row as an associative array
61: * Returns an associative array of strings that corresponds to the fetched row
62: * @return array
63: */
64: abstract function fetchAssoc();
65:
66: function fetchArrayOfAssoc()
67: {
68: $array = array();
69: while($row = $this->fetchAssoc())
70: {
71: $array[] = $row;
72: }
73: return $array;
74: }
75:
76: /**
77: * Fetch a result row as an associative array, a numeric array, or both
78: * Returns an array that corresponds to the fetched row and moves the internal data pointer ahead.
79: * @return array
80: */
81: abstract function fetchArray();
82:
83: /**
84: * Fetch a result row as an Object
85: * Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead.
86: * @return object
87: */
88: abstract function fetchObject($className='\\stdClass', array $params=array());
89:
90: function fetchArrayOfObject($className='\\stdClass', array $params=array())
91: {
92: $array = array();
93: while($row = $this->fetchObject($className, $params))
94: {
95: $array[] = $row;
96: }
97: return $array;
98: }
99:
100: /**
101: * Give the number of rows in the ResultSet
102: * This command is only valid for statements like SELECT or SHOW
103: * @return int
104: */
105: abstract function recordCount();
106:
107: abstract function recordAvailable();
108: }
109:
110: ?>