sfMySQLiDatabase.class.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. * (c) 2004-2006 Sean Kerr <sean@code-box.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * sfMySQLiDatabase provides connectivity for the MySQL brand database.
  12. * @see sfMySQLDatabase
  13. */
  14. class sfMySQLiDatabase extends sfMySQLDatabase
  15. {
  16. /**
  17. * Returns the appropriate connect method.
  18. *
  19. * @param bool $persistent Whether persistent connections are use or not
  20. * The MySQLi driver does not support persistent
  21. * connections so this argument is ignored.
  22. *
  23. * @return string name of connect method
  24. */
  25. protected function getConnectMethod($persistent)
  26. {
  27. return 'mysqli_connect';
  28. }
  29. /**
  30. * Selects the database to be used in this connection
  31. *
  32. * @param string $database Name of database to be connected
  33. *
  34. * @return bool true if this was successful
  35. */
  36. protected function selectDatabase($database)
  37. {
  38. return ($database != null && !@mysqli_select_db($this->connection, $database));
  39. }
  40. /**
  41. * Execute the shutdown procedure
  42. *
  43. * @throws <b>sfDatabaseException</b> If an error occurs while shutting down this database
  44. */
  45. public function shutdown()
  46. {
  47. if ($this->connection != null)
  48. {
  49. @mysqli_close($this->connection);
  50. }
  51. }
  52. }