summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2006-01-18 23:12:17 +0000
committertailor <cygnus@janrain.com>2006-01-18 23:12:17 +0000
commit8f528cf6e253ad3b963f8ed15cadacaa5f669d12 (patch)
tree461b1a63d137557e3926c4cfed2531d213acce7b /examples
parent9350c7f98eedcb81f28fea0f4242726f965f1848 (diff)
downloadphp-openid-8f528cf6e253ad3b963f8ed15cadacaa5f669d12.zip
php-openid-8f528cf6e253ad3b963f8ed15cadacaa5f669d12.tar.gz
php-openid-8f528cf6e253ad3b963f8ed15cadacaa5f669d12.tar.bz2
[project @ Added mysql store example code to example consumer]
Diffstat (limited to 'examples')
-rw-r--r--examples/consumer.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/consumer.php b/examples/consumer.php
index 855a344..88194a2 100644
--- a/examples/consumer.php
+++ b/examples/consumer.php
@@ -62,6 +62,40 @@ if ($store_type == 'sqlite') {
*/
$store->createTables();
+} else if ($store_type == 'mysql') {
+
+ require_once("Auth/OpenID/Store/SQLStore.php");
+
+ /**
+ * Assume that the database used by the MySQL store has already
+ * been created.
+ */
+ $dsn = array(
+ 'phptype' => 'mysql',
+ 'username' => 'openid_test',
+ 'password' => '',
+ 'hostspec' => 'dbtest',
+ 'database' => 'openid_test',
+ );
+
+ $db =& DB::connect($dsn);
+
+ if (PEAR::isError($db)) {
+ print "Database connection error: " .
+ $db->getMessage();
+ exit(0);
+ }
+
+ $store = new Auth_OpenID_MySQLStore($db);
+
+ /**
+ * This needs to be called once for the lifetime of the store, but
+ * calling it each time you use the store won't hurt anything
+ * (although it'll incur a slight performance pentalty because the
+ * tables will already exist).
+ */
+ $store->createTables();
+
} else if ($store_type == 'pgsql') {
require_once("Auth/OpenID/Store/SQLStore.php");