| 15817 |
anikendra |
1 |
<?php
|
|
|
2 |
ini_set('display_errors', '0'); # don't show any errors...
|
|
|
3 |
error_reporting(E_ALL ^ E_STRICT); # ...but do log them
|
|
|
4 |
|
|
|
5 |
class BrandpreferencesmapperShell extends AppShell {
|
|
|
6 |
public $uses = array('BrandPreference');
|
|
|
7 |
var $map = array();
|
|
|
8 |
|
|
|
9 |
public function main() {
|
|
|
10 |
$sql = "SELECT distinct user_id from brand_preferences bp WHERE (brand = 'Nokia' OR brand = 'Microsoft') AND status = 'show' AND category_id = 3";
|
|
|
11 |
$userIds = $this->BrandPreference->query($sql);
|
|
|
12 |
foreach ($userIds as $key => $value) {
|
|
|
13 |
$this->updatepreferences($value,3);
|
|
|
14 |
}
|
|
|
15 |
$sql = "SELECT distinct user_id from brand_preferences bp WHERE (brand = 'Nokia' OR brand = 'Microsoft') AND status = 'show' AND category_id = 5";
|
|
|
16 |
$userIds = $this->BrandPreference->query($sql);
|
|
|
17 |
foreach ($userIds as $key => $value) {
|
|
|
18 |
$this->updatepreferences($value,5);
|
|
|
19 |
}
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
public function updatepreferences($user,$categoy_id) {
|
|
|
23 |
$sql = "INSERT IGNORE INTO brand_preferences(user_id,brand,category_id,status,created,modified) VALUES(".$user['bp']['user_id'].",'Nokia',$categoy_id,'show',now(),now())";
|
|
|
24 |
$this->BrandPreference->query($sql);
|
|
|
25 |
$sql = "INSERT IGNORE INTO brand_preferences(user_id,brand,category_id,status,created,modified) VALUES(".$user['bp']['user_id'].",'Microsoft',$categoy_id,'show',now(),now())";
|
|
|
26 |
$this->BrandPreference->query($sql);
|
|
|
27 |
}
|
|
|
28 |
}
|