Hey folks:
I have 2 arrays: The keys are strings with integers (the bits) as values:
PHP Code:
$array_con = array(
name1=>1,
name2=>2,
name3=>4,
name4=>8,
);
and:
PHP Code:
$array_pro = array(
name1=>1,
name2=>2,
name3=>4,
name4=>8,
);
I want to use bitwise comparisons in a SQL query, to compare a single integer-value, itself a bitwise composition taken from a column in MySQL (3.22.32), with the values in the above array. Something like this:
PHP Code:
$sql .= "AND CatConsumer & {$sum_of_array_con_bits} AND CatProfessional & {$sum_of_array_pro_bits}";
Basically: "do there exist values in either array that compare in a bitwise manner with the single value in my db?"
But I get unpredictable results, which is why I'm making this posting
. Is a bitwise comparison on the sum of the arrays' values the correct way of doing things? I should add that I'm no expert at bitwise comparisons...
Can anyone suggest the correct method of performing this comparison? - cheers
Bookmarks