Bug #5588 [NEW]: Does not get/set prefs

From: Date: Mon, 03 Oct 2005 12:43:42 +0000
Subject: Bug #5588 [NEW]: Does not get/set prefs
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-6960@lists.php.net to get a copy of this message
From: svetoslavm at gmail dot com Operating system: WinXP PHP version: 4.3.10 Package: Documentation Bug Type: Bug Bug description: Does not get/set prefs Description: ------------ Package ============ Auth_PrefManager-1.1.4 obj dump ============ Set Country object(auth_prefmanager)(12) { ["_db"]=> object(db_mysql)(24) { ["phptype"]=> string(5) "mysql" ["dbsyntax"]=> string(5) "mysql" ["features"]=> array(7) { ["limit"]=> string(5) "alter" ["new_link"]=> string(5) "4.2.0" ["numrows"]=> bool(true) ["pconnect"]=> bool(true) ["prepare"]=> bool(false) ["ssl"]=> bool(false) ["transactions"]=> bool(true) } ["errorcode_map"]=> array(23) { [1004]=> int(-15) [1005]=> int(-15) [1006]=> int(-15) [1007]=> int(-5) [1008]=> int(-17) [1022]=> int(-5) [1044]=> int(-26) [1046]=> int(-14) [1048]=> int(-3) [1049]=> int(-27) [1050]=> int(-5) [1051]=> int(-18) [1054]=> int(-19) [1061]=> int(-5) [1062]=> int(-5) [1064]=> int(-2) [1091]=> int(-4) [1100]=> int(-21) [1136]=> int(-22) [1142]=> int(-26) [1146]=> int(-18) [1216]=> int(-3) [1217]=> int(-3) } ["connection"]=> resource(7) of type (mysql link) ["dsn"]=> array(9) { ["phptype"]=> string(5) "mysql" ["dbsyntax"]=> string(5) "mysql" ["username"]=> string(1) "a" ["password"]=> string(1) "a" ["protocol"]=> string(3) "tcp" ["hostspec"]=> string(9) "localhost" ["port"]=> bool(false) ["socket"]=> bool(false) ["database"]=> string(1) "b" } ["autocommit"]=> bool(true) ["transaction_opcount"]=> int(0) ["_db"]=> string(1) "b" ["_debug"]=> bool(false) ["_default_error_mode"]=> NULL ["_default_error_options"]=> NULL ["_default_error_handler"]=> string(0) "" ["_error_class"]=> string(8) "DB_Error" ["_expected_errors"]=> array(0) { } ["fetchmode"]=> int(1) ["fetchmode_object_class"]=> string(8) "stdClass" ["was_connected"]=> NULL ["last_query"]=> string(0) "" ["options"]=> array(8) { ["result_buffering"]=> int(500) ["persistent"]=> bool(false) ["ssl"]=> bool(false) ["debug"]=> int(0) ["seqname_format"]=> string(6) "%s_seq" ["autofree"]=> bool(false) ["portability"]=> int(0) ["optimize"]=> string(11) "performance" } ["last_parameters"]=> array(0) { } ["prepare_tokens"]=> array(0) { } ["prepare_types"]=> array(0) { } ["prepared_queries"]=> array(0) { } } ["_defaultUser"]=> string(11) "__default__" ["_returnDefaults"]=> bool(true) ["_table"]=> string(11) "preferences" ["_userColumn"]=> string(7) "user_id" ["_nameColumn"]=> string(7) "pref_id" ["_valueColumn"]=> string(10) "pref_value" ["_valueColumnQuoted"]=> string(10) "pref_value" ["_cacheName"]=> string(9) "prefCache" ["_lastError"]=> NULL ["_useCache"]=> bool(true) ["_serialize"]=> bool(true) } ============= database ============= user:a pass:a db:b Test script: --------------- example used =============================== <h1>Set Country</h1> <?php ini_set( "display_errors", 1 ); require_once('Auth/PrefManager.php'); // Create the PrefManager object. // Change the DSN to fit your database. $dsn = 'mysql://a:a@localhost/b'; // Enable serialization of data before saving, this ensures that the values are retrieved cleanly. $options = array('serialize' => true); // Create the object. $prefmanager = new Auth_PrefManager($dsn, $options); print( "<pre>" ); var_dump( $prefmanager ); // Set the default value (this doesn't need to be done everytime the script is run). $prefmanager->setDefaultPref("country", "Earth"); // Allow users to set their country and username. if (isset($_POST['submit'])) { $username = htmlspecialchars($_POST['username']); $prefmanager->setPref($username, 'country', $_POST['country']); } else if (isset($_POST['reset'])) { $username = htmlspecialchars($_POST['username']); $prefmanager->deletePref($username, 'country'); } else { $username = 'guest'; } ?> <h1>Welcome to the people of <?=$prefmanager->getPref($username, "country")?>!</h1> <h2>Set Country And Username</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>"> <label for="username">Username</label> <input name="username" value="<?=$username?>" /><br/> <label for="country">Country</label> <input name="country" value="<?=$prefmanager->getPref($username, 'country')?>"/><br/> <input type="submit" name="submit" value="Set Country" /> <input type="submit" name="reset" value="Reset Country" /> </form> ?> Expected result: ---------------- get/set prefs -- Edit bug report at http://pear.php.net/bugs/bug.php?id=5588&edit=1 --

« previous php.pear.doc (#6960) next »