Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

<?php
ini_set('display_errors', '0');     # don't show any errors...
error_reporting(E_ALL ^ E_STRICT);  # ...but do log them

class BrandpreferencesmapperShell extends AppShell {
        public $uses = array('BrandPreference');
        var $map = array();

        public function main() {
                $sql = "SELECT distinct user_id from brand_preferences bp WHERE (brand = 'Nokia' OR brand = 'Microsoft') AND status = 'show' AND category_id = 3";
                $userIds = $this->BrandPreference->query($sql);
                foreach ($userIds as $key => $value) {
                        $this->updatepreferences($value,3);
                }
                $sql = "SELECT distinct user_id from brand_preferences bp WHERE (brand = 'Nokia' OR brand = 'Microsoft') AND status = 'show' AND category_id = 5";
                $userIds = $this->BrandPreference->query($sql);
                foreach ($userIds as $key => $value) {
                        $this->updatepreferences($value,5);
                }
        }

        public function updatepreferences($user,$categoy_id) {
                $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())";
                $this->BrandPreference->query($sql);
                $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())";
                $this->BrandPreference->query($sql);
        }
}