* @package Mammut\DB */ abstract class Result extends \Mammut\StrictObject implements iFetchable, \Countable { /** * Fetches the current row number. * * @return integer The row number. */ abstract public function getRowNumber(); /** * Fetches the names of columns of the result. * * @return array A list of column names. */ abstract public function getColumns(); /** * Fetches the column info of one column. * * @return \Mammut\DB\Model\ColumnInfo A info object for $column, which could be a string or integer */ abstract public function getColumnInfo($column); /** * Fetches the number of columns returned. * * @return integer The number of columns */ public function getColumnCount() { return count($this->getColumns()); } public function fetchRowList() { $data = array(); while($next = $this->fetchRow()) $data[] = $next; return $data; } public function fetchArrayList() { $data = array(); while($next = $this->fetchArray()) $data[] = $next; return $data; } public function fetchObjectList($class = false, $param = array()) { $data = array(); while($next = $this->fetchObject($class, $param)) $data[] = $next; return $data; } /** * Implementation of \Countable interface, redirects to getRowCount. * This allows the usage of the count($result) method on database result sets. * * @return integer The number of rows returned. */ public function count(): int { return $this->getRowCount(); } /** * Closes the result set and frees all resources. */ abstract public function close(); }