You are here: RE: [PHP] Two websites need to share part of one database,suggestions please « PHP « IT news, forums, messages
RE: [PHP] Two websites need to share part of one database,suggestions please

Posted by Robert Cummings on 07/09/05 03:24

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. |
`------------------------------------------------------------'

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация