| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the symfony package.
|
|
|
5 |
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
6 |
* (c) 2004-2006 Sean Kerr <sean@code-box.org>
|
|
|
7 |
*
|
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
|
|
9 |
* file that was distributed with this source code.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* Provides support for session storage using a MySQL brand database
|
|
|
14 |
* using the MySQL improved API.
|
|
|
15 |
*
|
|
|
16 |
* <b>parameters:</b> see sfDatabaseSessionStorage
|
|
|
17 |
*
|
|
|
18 |
* @package symfony
|
|
|
19 |
* @subpackage storage
|
|
|
20 |
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
21 |
* @author Sean Kerr <sean@code-box.org>
|
|
|
22 |
* @author Julien Garand <julien.garand@gmail.com>
|
|
|
23 |
* @version SVN: $Id: sfMySQLiSessionStorage.class.php 24590 2009-11-30 18:28:13Z FabianLange $
|
|
|
24 |
*/
|
|
|
25 |
class sfMySQLiSessionStorage extends sfMySQLSessionStorage
|
|
|
26 |
{
|
|
|
27 |
/**
|
|
|
28 |
* Execute an SQL Query
|
|
|
29 |
*
|
|
|
30 |
* @param string $query The query to execute
|
|
|
31 |
* @return mixed The result of the query
|
|
|
32 |
*/
|
|
|
33 |
protected function db_query($query)
|
|
|
34 |
{
|
|
|
35 |
return mysqli_query($this->db, $query);
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Escape a string before using it in a query statement
|
|
|
40 |
*
|
|
|
41 |
* @param string $string The string to escape
|
|
|
42 |
* @return string The escaped string
|
|
|
43 |
*/
|
|
|
44 |
protected function db_escape($string)
|
|
|
45 |
{
|
|
|
46 |
return mysqli_real_escape_string($this->db, $string);
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* Count the rows in a query result
|
|
|
51 |
*
|
|
|
52 |
* @param resource $result Result of a query
|
|
|
53 |
* @return int Number of rows
|
|
|
54 |
*/
|
|
|
55 |
protected function db_num_rows($result)
|
|
|
56 |
{
|
|
|
57 |
return $result->num_rows;
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
* Extract a row from a query result set
|
|
|
62 |
*
|
|
|
63 |
* @param resource $result Result of a query
|
|
|
64 |
* @return array Extracted row as an indexed array
|
|
|
65 |
*/
|
|
|
66 |
protected function db_fetch_row($result)
|
|
|
67 |
{
|
|
|
68 |
return $result->fetch_row();
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* Returns the text of the error message from previous database operation
|
|
|
73 |
*
|
|
|
74 |
* @return string The error text from the last database function
|
|
|
75 |
*/
|
|
|
76 |
protected function db_error()
|
|
|
77 |
{
|
|
|
78 |
return mysqli_error($this->db);
|
|
|
79 |
}
|
|
|
80 |
}
|