Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Create Table:
- CREATE TABLE `adwords3_tier_brands` (
- `tier_brand_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `site_campaign_type_setting_id` smallint(4) unsigned NOT NULL,
- `tier_number` tinyint(2) unsigned NOT NULL,
- `base_multiplier` decimal(3,2) unsigned NOT NULL DEFAULT '4.00',
- `status` enum('initial','regress','repeat','graduate') NOT NULL DEFAULT 'repeat',
- `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (`tier_brand_id`),
- UNIQUE KEY `unique_key` (`site_campaign_type_setting_id`),
- KEY `site_campaign_type_setting_id` (`site_campaign_type_setting_id`),
- CONSTRAINT `a3tb_ibfk_1` FOREIGN KEY (`site_campaign_type_setting_id`) REFERENCES `adwords3_site_campaign_type_settings` (`site_campaign_type_setting_id`) ON DELETE CASCADE ON UPDATE CASCADE
- ) ENGINE=InnoDB AUTO_INCREMENT=200 DEFAULT CHARSET=utf8;
- Query:
- INSERT INTO adwords3_tier_brands
- (site_campaign_type_setting_id, tier_number, base_multiplier)
- VALUES(?,?,?)
- ON DUPLICATE KEY UPDATE
- tier_brand_id = LAST_INSERT_ID(tier_brand_id)
- , tier_number = ?
- , base_multiplier = ?;
- Function Call:
- try {
- $result = $this -> ExecuteQuery('query'
- , self::SAVEADJUSTTIERQUERY
- , array ( $this -> _site_campaign_type_setting_id
- , $this -> _Tier
- , $Tiers['BM']
- , $this -> _Tier
- , $Tiers['BM'] ) );
- echo "\nWTF: Tier Brand ID: ".$this -> _db -> lastInsertId()."\n";
- Function Called:
- private function ExecuteQuery($queryType, $query, $variables)
- {
- echo $this ->_cron_log -> AddDebugMessage("Begin ".__CLASS__."::".__FUNCTION__);
- $results = null;
- echo $this ->_cron_log -> AddDebugMessage("Query Type: ".$queryType);
- echo $this ->_cron_log -> AddDebugMessage("Query: ".$query);
- echo $this ->_cron_log -> AddDebugMessage("Variables: ".print_r($variables, true));
- try {
- switch($queryType)
- {
- case 'col':
- $results = $this -> _db -> fetchCol ( $query, $variables );
- break;
- case 'query':
- $this -> _db -> query ( $query, $variables );
- $results = $this -> _db -> lastInsertId();
- break;
- case 'row':
- $results = $this -> _db -> fetchRow ( $query, $variables );
- break;
- case 'all':
- $results = $this -> _db -> fetchAll ( $query, $variables );
- break;
- default:
- throw new Exception("Undefined query type in ".__CLASS__."::".__FUNCTION__);
- }
- }
- catch(Exception $ex)
- {
- echo $this -> _cron_log-> AddError("\nFailed ".__CLASS__."::".__FUNCTION__." for Site ID: {$this -> _site_id} with error: $ex");
- return false;
- }
- echo $this ->_cron_log -> AddDebugMessage("End ".__CLASS__."::".__FUNCTION__);
- return $results;
- }
Add Comment
Please, Sign In to add comment