(1 << $i) just generates the sequence 1, 2, 4, 8, 16, ...
In binary (ignoring signs) this is 1, 10, 100, 1000, 10000, ...
The bitwise and operator, &, compares bits from its operands. If both corresponding bits are set, that bit of the result will be set.
17 in binary is 10001
10001 & 1 = 1
10001 & 10 = 0
10001 & 100 = 0
10001 & 1000 = 0
10001 & 10000 = 10000
10000 in binary is 16 in base 10, which is a true value, hence $bit = 1 for this case.
Now, while this may work for you, if you are designing the database schema from scratch, you might want to give it another look - this is a space efficient way of storing data, but it isnt necessarily the best way, especially when you are using a relational database.