_callback = $callback; } /** * Fetch a row from the statement. * * The result will be processed by the callback when it is not `false`. * * @param string|int $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); } /** * {@inheritDoc} * * Each row in the result will be processed by the callback when it is not `false. */ public function fetchAll($type = parent::FETCH_TYPE_NUM) { $results = $this->_statement->fetchAll($type); return $results !== false ? array_map($this->_callback, $results) : false; } }