/** * Returns the number of rows returned of affected by last execution * * @return int */ public function rowCount() { if (preg_match('/^(?:DELETE|UPDATE|INSERT)/i', $this->_statement->queryString)) { $changes = $this->_driver->prepare('SELECT CHANGES()'); $changes->execute(); $count = $changes->fetch()[0]; $changes->closeCursor(); return (int) $count; } return parent::rowCount(); }
/** * {@inheritDoc} */ public function fetchAll($type = 'num') { if ($this->_allFetched) { return $this->_records; } $this->_records = parent::fetchAll($type); $this->_count = count($this->_records); $this->_allFetched = true; $this->_statement->closeCursor(); return $this->_records; }
/** * Constructor * * @param \Cake\Database\StatementInterface $statement The statement to decorate. * @param \Cake\Database\Driver $driver The driver instance used by the statement. * @param callable $callback The callback to apply to results before they are returned. */ public function __construct($statement, $driver, $callback) { parent::__construct($statement, $driver); $this->_callback = $callback; }