sfMySQLiSessionStorage.class.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. * Provides support for session storage using a MySQL brand database
  12. * using the MySQL improved API.
  13. *
  14. * <b>parameters:</b> see sfDatabaseSessionStorage
  15. *
  16. * @package symfony
  17. * @subpackage storage
  18. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  19. * @author Sean Kerr <sean@code-box.org>
  20. * @author Julien Garand <julien.garand@gmail.com>
  21. * @version SVN: $Id: sfMySQLiSessionStorage.class.php 15545 2009-02-16 21:47:19Z dwhittle $
  22. */
  23. class sfMySQLiSessionStorage extends sfMySQLSessionStorage
  24. {
  25. /**
  26. * Execute an SQL Query
  27. *
  28. * @param string $query The query to execute
  29. * @return mixed The result of the query
  30. */
  31. protected function db_query($query)
  32. {
  33. return mysqli_query($this->db, $query);
  34. }
  35. /**
  36. * Escape a string before using it in a query statement
  37. *
  38. * @param string $string The string to escape
  39. * @return string The escaped string
  40. */
  41. protected function db_escape($string)
  42. {
  43. return mysqli_real_escape_string($this->db, $string);
  44. }
  45. /**
  46. * Count the rows in a query result
  47. *
  48. * @param resource $result Result of a query
  49. * @return int Number of rows
  50. */
  51. protected function db_num_rows($result)
  52. {
  53. return $result->num_rows;
  54. }
  55. /**
  56. * Extract a row from a query result set
  57. *
  58. * @param resource $result Result of a query
  59. * @return array Extracted row as an indexed array
  60. */
  61. protected function db_fetch_row($result)
  62. {
  63. return $result->fetch_row();
  64. }
  65. }