[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/SessionHandler/ -> sapdb.php (source)

   1  <?php
   2  
   3  require_once dirname(__FILE__) . '/sql.php';
   4  
   5  /**
   6   * SessionHandler implementation for PHP's PEAR database abstraction layer.
   7   *
   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   * be chopped off), and setting it to 0 DOES NOT work - that doesn't mean no
  12   * limit, for some reason. odbc.defaultlrl = 32768 seems to work pretty well
  13   * (using MSSQL-2000).
  14   *
  15   * Required parameters:<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.</pre>
  21   *
  22   * Optional parameters:<pre>
  23   *   'table'     The name of the sessiondata table in 'database'.  Default is
  24   *               'horde_sessionhandler'.</pre>
  25   *
  26   * The table structure for the SessionHandler can be found in
  27   * horde/scripts/sql/horde_sessionhandler.sapdb.sql.
  28   *
  29   * $Horde: framework/SessionHandler/SessionHandler/sapdb.php,v 1.13.12.8 2006/01/01 21:28:34 jan Exp $
  30   *
  31   * Copyright 2002-2006 Mike Cochrane <mike@graftonhall.co.nz>
  32   *
  33   * See the enclosed file COPYING for license information (LGPL). If you
  34   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  35   *
  36   * @author  Mike Cochrane <mike@graftonhall.co.nz>
  37   * @since   Horde 3.0
  38   * @package Horde_SessionHandler
  39   */
  40  class SessionHandler_sapdb extends SessionHandler_sql {
  41  
  42      /**
  43       * Constructs a new SQL SessionHandler object.
  44       *
  45       * @param array $params  A hash containing connection parameters.
  46       */
  47      function SessionHandler_sapdb($params = array())
  48      {
  49          $params['phptype'] = 'odbc';
  50          parent::SessionHandler_sql($params);
  51      }
  52  
  53      /**
  54       * Read the data for a particular session identifier from the
  55       * SessionHandler backend.
  56       *
  57       * @param string $id  The session identifier.
  58       *
  59       * @return string  The session data.
  60       */
  61      function read($id)
  62      {
  63          /* Make sure we have a valid database connection. */
  64          $this->_connect();
  65  
  66          /* Begin a transaction. */
  67          $result = $this->_db->autocommit(false);
  68          if (is_a($result, 'PEAR_Error')) {
  69              Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
  70              return '';
  71          }
  72  
  73          /* Build the SQL query. */
  74          $query = sprintf('SELECT session_data FROM %s WHERE session_id = %s',
  75                           $this->_params['table'],
  76                           $this->_db->quote($id));
  77  
  78          /* Log the query at a DEBUG log level. */
  79          Horde::logMessage(sprintf('SQL Query by SessionHandler_sql::read(): query = "%s"', $query),
  80                            __FILE__, __LINE__, PEAR_LOG_DEBUG);
  81  
  82          /* Execute the query */
  83          $result = odbc_exec($this->_db->connection, $query);
  84          odbc_longreadlen($result, 1048576);
  85  
  86          /* Fetch the value */
  87          odbc_fetch_row($result, 0);
  88          $data = odbc_result($result, 'session_data');
  89  
  90          /* Clean up */
  91          odbc_free_result($result);
  92  
  93          return $data;
  94      }
  95  
  96  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7