_callback = $callback; } /** * Fetch a row from the statement. * * The result will be processed by the callback when it is not `false`. * * @param string $type Either 'num' or 'assoc' to indicate the result format you would like. * @return array|false */ public function fetch($type = parent::FETCH_TYPE_NUM) { $callback = $this->_callback; $row = $this->_statement->fetch($type); return $row === false ? $row : $callback($row); } /** * Fetch all rows from the statement. * * Each row in the result will be processed by the callback when it is not `false. * * @param string $type Either 'num' or 'assoc' to indicate the result format you would like. * @return array */ public function fetchAll($type = parent::FETCH_TYPE_NUM) { return array_map($this->_callback, $this->_statement->fetchAll($type)); } }