3
require_once dirname(__FILE__) . '/sql.php';
6
* SessionHandler implementation for PHP's PEAR database abstraction layer.
8
* If you access your database through ODBC, you will almost certainly need
9
* to change PHP's default value for odbc.defaultlrl (this is a php.ini
10
* setting). The default is 4096, which is too small (your session data will
11
* data will be chopped off), and setting it to 0 DOES NOT work - that
12
* doesn't mean no limit, for some reason. odbc.defaultlrl = 32768
13
* seems to work pretty well (using MSSQL-2000).
15
* Required values for $params:<pre>
16
* 'hostspec' -- The hostname of the database server.
17
* 'protocol' -- The communication protocol ('tcp', 'unix', etc.).
18
* 'username' -- The username with which to connect to the database.
19
* 'password' -- The password associated with 'username'.
20
* 'database' -- The name of the database.
21
* 'table' -- The name of the sessiondata table in 'database'.</pre>
23
* The table structure can be created by the scripts/db/sessionhandler.sql
26
* $Horde: framework/SessionHandler/SessionHandler/sapdb.php,v 1.13.12.2 2005/02/01 19:07:15 chuck Exp $
28
* Copyright 2002-2005 Mike Cochrane <mike@graftonhall.co.nz>
30
* See the enclosed file COPYING for license information (LGPL). If you
31
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
33
* @author Mike Cochrane <mike@graftonhall.co.nz>
35
* @package Horde_SessionHandler
37
class SessionHandler_sapdb extends SessionHandler_sql {
39
/** Hash containing connection parameters. */
40
var $_params = array();
42
/** Handle for the current database connection.
47
* Boolean indicating whether or not we're connected to the SQL
49
var $_connected = false;
52
* Constructs a new SQL SessionHandler object.
54
* @param array $params A hash containing connection parameters.
56
function SessionHandler_sapdb($params = array())
58
$this->_params = $params;
59
$this->_params['phptype'] = 'odbc';
64
/* Make sure we have a valid database connection. */
67
/* Build the SQL query. */
68
$query = sprintf('SELECT session_data FROM %s WHERE session_id = %s',
69
$this->_params['table'],
70
$this->_db->quote($id));
72
/* Log the query at a DEBUG log level. */
73
Horde::logMessage(sprintf('SQL Query by SessionHandler_sql::read(): query = "%s"', $query),
74
__FILE__, __LINE__, PEAR_LOG_DEBUG);
76
/* Execute the query */
77
$result = odbc_exec($this->_db->connection, $query);
78
odbc_longreadlen($result, 1024*1024);
81
odbc_fetch_row($result, 0);
82
$data = odbc_result($result, 'session_data');
85
odbc_free_result($result);