SqliteStatement.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * PHP Version 5.4
  4. *
  5. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  6. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * For full copyright and license information, please see the LICENSE.txt
  10. * Redistributions of files must retain the above copyright notice.
  11. *
  12. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  13. * @link http://cakephp.org CakePHP(tm) Project
  14. * @since CakePHP(tm) v 3.0.0
  15. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  16. */
  17. namespace Cake\Database\Statement;
  18. /**
  19. * Statement class meant to be used by an Sqlite driver
  20. *
  21. */
  22. class SqliteStatement extends BufferedStatement {
  23. /**
  24. * Returns the number of rows returned of affected by last execution
  25. *
  26. * @return int
  27. */
  28. public function rowCount() {
  29. if (preg_match('/^(?:DELETE|UPDATE|INSERT)/i', $this->_statement->queryString)) {
  30. $changes = $this->_driver->prepare('SELECT CHANGES()');
  31. $changes->execute();
  32. return $changes->fetch()[0];
  33. }
  34. return parent::rowCount();
  35. }
  36. }