If you used just integers then you wouldn't be able to work backwards from
the totalled number. For example:

- is_low_socring = 1
- is_high_scoring = 2
- is_virus = 3
- is_badcontent = 4

If I had something that was just bad content it would be a 4. But If I had
something that was low_scoring and a virus it would also be 4... hmmm. But
if I use binary...


- is_low_socring = 1
- is_high_scoring = 2
- is_virus = 4
- is_badcontent = 8

ONLY bad_content can be an 8, only low_scoring AND virus can be a 5 .. etc
etc.

Hope that helps

On Wed, Apr 29, 2009 at 6:01 PM, Richtermeister <[email protected]> wrote:

>
> Hi Gareth,
>
> I just read your blog entry on that subject, and I have to admit that
> it never occurred to me to use bits to store multiple flags in one
> column. I like it! :) Thanks.
>
> My question, if I may, is why the classification column is not just an
> integer? What is the Criteria::BINARY_AND for?
>
> Thanks for enlightening me :)
> Have a great day.
> Daniel
>
>
> On Apr 29, 1:09 am, Gareth McCumskey <[email protected]> wrote:
> > Hi all,
> >
> > I need the great minds that populate this liust to assist me with a small
> > dilema. We currently use an integer field that stores a range of values
> as a
> > bitwise number depending on certain criteria of an item stored in the db.
> > What we want to do now is write a sql query like:
> >
> > SELECT [columns] FROM [tablename] WHERE classification & 1 AND
> > classification & ~2
> >
> > I am struggling to find the negation (~) operator as part of the criteria
> > syntax. So far I have:
> >
> > $status_criterion = $c->getNewCriterion(MailDetailsPeer::CLASSIFICATION,
> 1,
> > Criteria::BINARY_AND);
> >
> $status_criterion->addAnd($c->getNewCriterion(MailDetailsPeer::CLASSIFICATION,
> > 2 , Criteria::BINARY_AND));
> >
> > As you can see I have no negation on the second-line because I do not
> know
> > how I should do that. There aren't any obvious options as part of Propel.
> >
> > ANy help would be appreciated guys :)
> >
> > --
> > Gareth McCumskeyhttp://garethmccumskey.blogspot.com
> > twitter: @garethmcc
> >
>


-- 
Gareth McCumskey
http://garethmccumskey.blogspot.com
twitter: @garethmcc

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to