Guest User

Untitled

a guest
Oct 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. Create Table:
  2. CREATE TABLE `adwords3_tier_brands` (
  3. `tier_brand_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  4. `site_campaign_type_setting_id` smallint(4) unsigned NOT NULL,
  5. `tier_number` tinyint(2) unsigned NOT NULL,
  6. `base_multiplier` decimal(3,2) unsigned NOT NULL DEFAULT '4.00',
  7. `status` enum('initial','regress','repeat','graduate') NOT NULL DEFAULT 'repeat',
  8. `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  9. PRIMARY KEY (`tier_brand_id`),
  10. UNIQUE KEY `unique_key` (`site_campaign_type_setting_id`),
  11. KEY `site_campaign_type_setting_id` (`site_campaign_type_setting_id`),
  12. 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
  13. ) ENGINE=InnoDB AUTO_INCREMENT=200 DEFAULT CHARSET=utf8;
  14.  
  15. Query:
  16. INSERT INTO adwords3_tier_brands
  17. (site_campaign_type_setting_id, tier_number, base_multiplier)
  18. VALUES(?,?,?)
  19. ON DUPLICATE KEY UPDATE
  20. tier_brand_id = LAST_INSERT_ID(tier_brand_id)
  21. , tier_number = ?
  22. , base_multiplier = ?;
  23.  
  24. Function Call:
  25. try {
  26. $result = $this -> ExecuteQuery('query'
  27. , self::SAVEADJUSTTIERQUERY
  28. , array ( $this -> _site_campaign_type_setting_id
  29. , $this -> _Tier
  30. , $Tiers['BM']
  31. , $this -> _Tier
  32. , $Tiers['BM'] ) );
  33.  
  34. echo "\nWTF: Tier Brand ID: ".$this -> _db -> lastInsertId()."\n";
  35.  
  36. Function Called:
  37. private function ExecuteQuery($queryType, $query, $variables)
  38. {
  39. echo $this ->_cron_log -> AddDebugMessage("Begin ".__CLASS__."::".__FUNCTION__);
  40.  
  41. $results = null;
  42. echo $this ->_cron_log -> AddDebugMessage("Query Type: ".$queryType);
  43. echo $this ->_cron_log -> AddDebugMessage("Query: ".$query);
  44. echo $this ->_cron_log -> AddDebugMessage("Variables: ".print_r($variables, true));
  45.  
  46. try {
  47. switch($queryType)
  48. {
  49. case 'col':
  50. $results = $this -> _db -> fetchCol ( $query, $variables );
  51. break;
  52. case 'query':
  53. $this -> _db -> query ( $query, $variables );
  54. $results = $this -> _db -> lastInsertId();
  55. break;
  56. case 'row':
  57. $results = $this -> _db -> fetchRow ( $query, $variables );
  58. break;
  59. case 'all':
  60. $results = $this -> _db -> fetchAll ( $query, $variables );
  61. break;
  62. default:
  63. throw new Exception("Undefined query type in ".__CLASS__."::".__FUNCTION__);
  64. }
  65. }
  66. catch(Exception $ex)
  67. {
  68. echo $this -> _cron_log-> AddError("\nFailed ".__CLASS__."::".__FUNCTION__." for Site ID: {$this -> _site_id} with error: $ex");
  69. return false;
  70. }
  71. echo $this ->_cron_log -> AddDebugMessage("End ".__CLASS__."::".__FUNCTION__);
  72. return $results;
  73. }
Add Comment
Please, Sign In to add comment