diff options
author | tailor <cygnus@janrain.com> | 2006-05-16 21:03:25 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2006-05-16 21:03:25 +0000 |
commit | 5c965d951070ae576274b4eb8c4951a4e2989107 (patch) | |
tree | 46d00caf28c6f6248062d156e4c80a31b31c4aa0 /Auth/OpenID/SQLStore.php | |
parent | 44fb769d0c92adddbd11d1ffe205a179a8ecd0ba (diff) | |
download | php-openid-5c965d951070ae576274b4eb8c4951a4e2989107.zip php-openid-5c965d951070ae576274b4eb8c4951a4e2989107.tar.gz php-openid-5c965d951070ae576274b4eb8c4951a4e2989107.tar.bz2 |
[project @ Updated SQL store to actually work without PEAR.]
Diffstat (limited to 'Auth/OpenID/SQLStore.php')
-rw-r--r-- | Auth/OpenID/SQLStore.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Auth/OpenID/SQLStore.php b/Auth/OpenID/SQLStore.php index a23c045..6aef0b0 100644 --- a/Auth/OpenID/SQLStore.php +++ b/Auth/OpenID/SQLStore.php @@ -15,9 +15,14 @@ /** * Require the PEAR DB module because we'll need it for the SQL-based - * stores implemented here. + * stores implemented here. We silence any errors from the inclusion + * because it might not be present, and a user of the SQL stores may + * supply an Auth_OpenID_DatabaseConnection instance that implements + * its own storage. */ -require_once 'DB.php'; +global $__Auth_OpenID_PEAR_AVAILABLE; +$__Auth_OpenID_PEAR_AVAILABLE = include_once 'DB.php'; + /** * @access private */ @@ -76,6 +81,8 @@ class Auth_OpenID_SQLStore extends Auth_OpenID_OpenIDStore { $associations_table = null, $nonces_table = null) { + global $__Auth_OpenID_PEAR_AVAILABLE; + $this->settings_table_name = "oid_settings"; $this->associations_table_name = "oid_associations"; $this->nonces_table_name = "oid_nonces"; @@ -95,8 +102,13 @@ class Auth_OpenID_SQLStore extends Auth_OpenID_OpenIDStore { $this->connection = $connection; // Be sure to set the fetch mode so the results are keyed on - // column name instead of column index. - $this->connection->setFetchMode(DB_FETCHMODE_ASSOC); + // column name instead of column index. This is a PEAR + // constant, so only try to use it if PEAR is present. Note + // that Auth_Openid_Databaseconnection instances need not + // implement ::setFetchMode for this reason. + if ($__Auth_OpenID_PEAR_AVAILABLE) { + $this->connection->setFetchMode(DB_FETCHMODE_ASSOC); + } if ($settings_table) { $this->settings_table_name = $settings_table; |