I've received this data from an app. My parameter list:
- catids = 1, 2, 3
- subscriptions = 1, 1, 0 [ 0 = keep subscribed and 1 = unsubscribe for catids in this order]
- appuser_id = XXX
Now I have to update my subscription table according to data received. The schema is as follows:
--cat_id--appuser_id
1 | 10 |
2 | 10 |
3 | 10 |
4 | 20 |
5 | 20 |
---------------------
So how can I do this neatly considering query performance? The approach I could think of is:
- Get all subscriptions whose value is 1.
- Find out respective catids for values found in step 1.
- Delete those entries from table.
I can reach up to step 1 only. I can't think of a way to match entries found in step 1 with their respective catid.
$cat = '1,2,3';
$subs = '1,1,0';
$catA = explode(',',$cat);
$subsA = explode(',',$subs);
$deleteSubList = array();
foreach($subsA as $v){
if($v == 1){
array_push($deleteSubList,$v);
}
}
print_r($deleteSubList);
This gives me Array ( [0] => 1 [1] => 1 ). How do I know that it belongs to one of the categories from $catA array?