1 | <?php |
||
7 | class PdoHandler extends PdoSessionHandler |
||
8 | { |
||
9 | /** |
||
10 | * No locking is done. This means sessions are prone to loss of data due to |
||
11 | * race conditions of concurrent requests to the same session. The last session |
||
12 | * write will win in this case. It might be useful when you implement your own |
||
13 | * logic to deal with this like an optimistic approach. |
||
14 | */ |
||
15 | const LOCK_NONE = 0; |
||
16 | |||
17 | /** |
||
18 | * Creates an application-level lock on a session. The disadvantage is that the |
||
19 | * lock is not enforced by the database and thus other, unaware parts of the |
||
20 | * application could still concurrently modify the session. The advantage is it |
||
21 | * does not require a transaction. |
||
22 | * This mode is not available for SQLite and not yet implemented for oci and sqlsrv. |
||
23 | */ |
||
24 | const LOCK_ADVISORY = 1; |
||
25 | |||
26 | /** |
||
27 | * Issues a real row lock. Since it uses a transaction between opening and |
||
28 | * closing a session, you have to be careful when you use same database connection |
||
29 | * that you also use for your application logic. This mode is the default because |
||
30 | * it's the only reliable solution across DBMSs. |
||
31 | */ |
||
32 | const LOCK_TRANSACTIONAL = 2; |
||
33 | |||
34 | /** |
||
35 | * @var \PDO|null PDO instance or null when not connected yet |
||
36 | */ |
||
37 | private $pdo; |
||
|
|||
38 | |||
39 | /** |
||
40 | * @var string|null|false DSN string or null for session.save_path or false when lazy connection disabled |
||
41 | */ |
||
42 | private $dsn = false; |
||
43 | |||
44 | /** |
||
45 | * @var string Database driver |
||
46 | */ |
||
47 | private $driver; |
||
48 | |||
49 | /** |
||
50 | * @var string Table name |
||
51 | */ |
||
52 | private $table; |
||
53 | |||
54 | /** |
||
55 | * @var string Column for cache id |
||
56 | */ |
||
57 | private $idCol; |
||
58 | |||
59 | /** |
||
60 | * @var string Column for cache data |
||
61 | */ |
||
62 | private $dataCol; |
||
63 | |||
64 | /** |
||
65 | * @var string Column for lifetime |
||
66 | */ |
||
67 | private $lifetimeCol; |
||
68 | |||
69 | /** |
||
70 | * @var string Column for timestamp |
||
71 | */ |
||
72 | private $timeCol; |
||
73 | |||
74 | /** |
||
75 | * @var string Username when lazy-connect |
||
76 | */ |
||
77 | private $username = ''; |
||
78 | |||
79 | /** |
||
80 | * @var string Password when lazy-connect |
||
81 | */ |
||
82 | private $password = ''; |
||
83 | |||
84 | /** |
||
85 | * @var array Connection options when lazy-connect |
||
86 | */ |
||
87 | private $connectionOptions = array(); |
||
88 | |||
89 | /** |
||
90 | * @var int The strategy for locking, see constants |
||
91 | */ |
||
92 | private $lockMode = self::LOCK_TRANSACTIONAL; |
||
93 | |||
94 | public function __construct($pdoOrDsn = null, array $options = array()) |
||
117 | |||
118 | public function createTable() |
||
138 | |||
139 | public function fetch($key){ |
||
142 | |||
143 | public function save($key, $info){ |
||
146 | |||
147 | public function delete($key){ |
||
150 | } |