Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.6.4

Request #7089 Add a WHERE clause in Auth request with DB container
Submitted: 2006-03-10 14:46 UTC
From: jlb at freelug dot org Assigned: aashley
Status: Closed Package: Auth (version 1.3.0)
PHP Version: 4.3.10 OS: n/a
Roadmaps: (Not assigned)    
Subscription  


 [2006-03-10 14:46 UTC] jlb at freelug dot org (JLB)
Description: ------------ I had a need to do a more complicated query to authenticate user from an existant database. So i had a new option to DB Container : db_where_options This options is some WHERE condition, like "status=1" that will be added to the end of select query to authenticate user. this is the little patch against Auth/Container/DB.php, use like you want (i hope it will be included in the next release :-) ) --- DB.php.orig 2006-03-10 15:19:36.000000000 +0100 +++ DB.php 2006-03-10 15:21:37.000000000 +0100 @@ -193,6 +193,7 @@ $this->options['db_fields'] = ''; $this->options['cryptType'] = 'md5'; $this->options['db_options'] = array(); + $this->options['db_where_options'] = ''; } // }}} @@ -272,6 +273,12 @@ $query = "SELECT ".$sql_from. " FROM ".$this->options['table']. " WHERE ".$this->options['usernamecol']." = ".$this->db->quoteSmart($username); + + // check if there is an optional parameter db_where_options + if ( $this->options['db_where_options'] != '' ){ + // there is one, so add it to the query + $query .= " AND ".$this->options['db_where_options']; + } $res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC);

Comments

 [2006-08-31 13:20 UTC] janisto (janisto)
Please include this in the next release. This is exactly what I need.
 [2006-12-21 04:53 UTC] aashley at php dot net (Adam Ashley)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.