RE: [PHP] Two websites need to share part of one database,suggestions please

From: Date: Sat, 09 Jul 2005 00:24:43 +0000
Subject: RE: [PHP] Two websites need to share part of one database,suggestions please
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-218375@lists.php.net to get a copy of this message
On Fri, 2005-07-08 at 19:46, Chris W. Parker wrote: > Robert Cummings <mailto:robert@interjinn.com> > on Friday, July 08, 2005 3:32 PM said: > > > > Use a bitvector field in the table and use a bitmask for filtering for > > which sites can access what products. > > I think I understand what a bitmask is after doing some research but > would you please give me an example so I can apply what I've read? > > > Then similarly for > > customizations (presuming good database normalization) you can extend > > this to customizations, specials, etc, etc. This is only one possible > > solution of many, you could have the database list in another table, > > but I thought I'd skip a join since you only mention two sites. > > Again, I think I understand what you're suggesting, but the problem is > that I'm not sure how to apply it. Example please, if you will. An over simplification :) $site1 = 1; $site2 = 2; $currSite = $site2; $qString = "SELECT " ." * " ."FROM " ." products " ."WHERE " ." id = ".addSlashes( $someId )." " ." AND " ." siteMask & ".(1 << $currSite)." "; Note that the query uses boolean & and not logical && which allows it to match individual bits. Thus siteMask should have one of the following values: (1 << 1) == 2 // only site1 can use the product. (1 << 2) == 4 // only site2 can use the product. ((1 << 1) | (1 << 2)) == 6 // both sites can use the product. HTH, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#218375) next »