当前位置: 首页>>代码示例>>PHP>>正文


PHP DataManager::Query方法代码示例

本文整理汇总了PHP中DataManager::Query方法的典型用法代码示例。如果您正苦于以下问题:PHP DataManager::Query方法的具体用法?PHP DataManager::Query怎么用?PHP DataManager::Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataManager的用法示例。


在下文中一共展示了DataManager::Query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: controller_abtests

 function controller_abtests($args, $output = "inline")
 {
     $user = User::Singleton();
     if (!($user->isLoggedIn() && $user->HasRole("ADMIN"))) {
         return ComponentManager::fetch("elation.accessviolation", NULL, "componentresponse");
     }
     $data = DataManager::singleton();
     $req = $this->root->request['args'];
     $vars['err_msg'] = "";
     if ($req['save_scope']) {
         // prepare to save new abtest - make sure we are not creating an active collision
         if ($req['status'] == 'active') {
             $sql = "SELECT * FROM userdata.abtest\n          WHERE status='active'\n          AND cobrand=:cobrand\n          AND effective_dt != :effective_dt";
             if ($req['save_scope'] != 'all') {
                 $sql .= " AND role = :role";
             }
             $query = DataManager::Query("db.abtests.abtest:nocache", $sql, array(":cobrand" => $req['cobrand'], ":effective_dt" => $req['effective_dt'], ":role" => $req['role']));
             if ($query->results) {
                 $vars['err_msg'] = "***Save Aborted -- Active Status Collision -- " . $req['cobrand'] . " " . $query->results[0]->effective_dt;
             }
         }
         if (!$vars['err_msg']) {
             // write new abtest group to database
             $roles = array($req['role']);
             if ($req['save_scope'] == 'all') {
                 $roles = array('dev', 'test', 'live', 'elation');
             }
             foreach ($roles as $role) {
                 DataManager::Query("db.abtests.abtest:nocache", "DELETE FROM userdata.abtest\n                          WHERE effective_dt=:effective_dt\n                          AND cobrand=:cobrand\n                          AND role=:role", array(":effective_dt" => $req["effective_dt"], ":cobrand" => $req["cobrand"], ":role" => $role));
                 foreach ($req['version'] as $k => $v) {
                     DataManager::Query("db.abtests.abtest:nocache", "INSERT INTO userdata.abtest\n                            SET version=:version,\n                               percent=:percent,\n                                effective_dt=:effective_dt,\n                                duration_days=:duration_days,\n                                status=:status,\n                                cobrand=:cobrand,\n                                config=:config,\n                                role=:role,\n                                is_base=:is_base", array(":version" => $v, ":percent" => $req['percent'][$k], ":effective_dt" => $req['effective_dt'], ":duration_days" => $req['duration'], ":status" => $req['status'], ":cobrand" => $req['cobrand'], ":config" => $req['config'][$k], ":role" => $role, ":is_base" => $req['isbase_position'] == $k ? '1' : '0'));
                 }
             }
         }
         //fall into new lookup---
     }
     $query = DataManager::Query("db.abtests.abtest:nocache", "SELECT * FROM userdata.abtest ORDER BY status, role, cobrand, effective_dt", array());
     $vars['last_version'] = 0;
     foreach ($query->results as $res) {
         $vars['abtest'][$res->status][$res->role][$res->cobrand][$res->effective_dt][] = array('Version' => $res->version, 'Percent' => $res->percent, 'Duration' => $res->duration_days, 'Config' => $res->config, 'IsBase' => $res->is_base);
         if ($vars['last_version'] < $res->version) {
             $vars['last_version'] = $res->version;
         }
     }
     $config = ConfigManager::singleton();
     $cobrands = $config->GetCobrandList('name');
     $cobrand_test = "";
     foreach ($cobrands['cobrand'] as $k => $v) {
         preg_match('#\\.([^.]+)#', $v->name, $matches);
         if ($cobrand_test != $matches[1]) {
             $vars['cobrands'][] = $matches[1];
         }
         $cobrand_test = $matches[1];
     }
     for ($i = 0; $i < 40; $i++) {
         $vars['dates'][] = date("Y-m-d", 86400 * $i + time());
     }
     $content = $this->GetTemplate("./abtests.tpl", $vars);
     if ($output == "ajax") {
         $ret["tf_debug_tab_abtests"] = $content;
     } else {
         $ret = $content;
     }
     return $ret;
 }
开发者ID:ameyer430,项目名称:elation,代码行数:65,代码来源:elation.php

示例2: GetCobrandidAndRevision

 /**
  * get the cobrandid and revision information
  *
  * @param $name, $role, $nocache
  * @return array
  */
 function GetCobrandidAndRevision($nocache = false)
 {
     $ret = array();
     if ($this->name && $this->role) {
         $query = DataManager::Query("db.config.version.{$this->name}.{$this->role}" . ($nocache ? ":nocache" : ""), "SELECT config.version.cobrandid, config.version.revision FROM config.version INNER JOIN config.cobrand on config.version.cobrandid=config.cobrand.cobrandid WHERE config.cobrand.name=:name and config.version.role=:role", array(":name" => $this->name, ":role" => $this->role));
         if ($query && $query->NumResults() == 1) {
             $version_info = $query->GetResult(0);
             $this->cobrandid = $version_info->cobrandid;
             $this->revision = $version_info->revision;
         } elseif ($nocache == true) {
             if ($this->AddRevisionByName($name, $role)) {
                 $this->GetCobrandidAndRevision($name, $role);
             }
         }
     }
     return array("cobrandid" => $this->cobrandid, "revision" => $this->revision);
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:23,代码来源:configmanager_class.php

示例3: processShutdown

 /**
  * This function will be called at script shutdown via PHP script shutdown.
  * It will loop through the errors and warning and send one email
  * and/or write the errors/warnings to the file IO.
  */
 public static function processShutdown()
 {
     global $webapp;
     // settings
     $sitecfg = array("logger" => Configmanager::get("logger"));
     $sitecfg = $sitecfg["logger"]["email"] && $sitecfg["logger"]["file"] ? $sitecfg : self::getDefaultLoggerConfig();
     // email section
     $level_setting = self::convertLevelToNumeric($sitecfg["logger"]["email"]["level"]);
     $interval = $sitecfg["logger"]["email"]["interval"] > 0 ? $sitecfg["logger"]["email"]["interval"] : 10;
     // default to 10 minutes
     if ($level_setting > 0 && $lvl <= $level_setting && $sitecfg["logger"]["email"]["email_to"]) {
         $data_mgr = DataManager::singleton();
         // loop through them and send the ones that should be sent
         $email_msg = "";
         foreach (self::$log_emails as $email) {
             if ($email["level"] <= $level_setting) {
                 $cache_val = DataManager::Query("memcache.data", $email["cache_key"]);
                 if (time() - $cache_val["sent_timestamp"] >= $interval * 60) {
                     $num_times = $cache_val["count"] + 1;
                     $header = "From: " . $_SERVER["SERVER_ADMIN"] . "\n";
                     $subject = "Warning/Error message from " . $_SERVER["SERVER_ADMIN"];
                     // append the # of times this warning/error has occurred
                     $email_msg .= self::NEWLINE . self::NEWLINE . self::NEWLINE . "Number of times happened since last email = " . $num_times . self::NEWLINE . $email["content"];
                     if ($data_mgr) {
                         $cache_val["count"] = 0;
                         $cache_val["sent_timestamp"] = time();
                         DataManager::QueryInsert("memcache.data", $email["cache_key"], $cache_val);
                     }
                 } else {
                     if ($data_mgr) {
                         $cache_val["count"] += 1;
                         DataManager::QueryInsert("memcache.data", $email["cache_key"], $cache_val);
                     }
                 }
             }
         }
         if ($email_msg) {
             mail($sitecfg["logger"]["email"]["email_to"], $subject, $email_msg, $header);
         }
     }
     // log file to IO
     $level_setting = self::convertLevelToNumeric($sitecfg["logger"]["file"]["level"]);
     if ($level_setting > 0 && $sitecfg["logger"]["file"]["path"]) {
         $file_msg = "";
         foreach (self::$log_files as $file) {
             if ($file["level"] <= $level_setting) {
                 $file_msg .= $file["content"] . self::NEWLINE;
             }
         }
         $folder = rtrim($sitecfg["logger"]["file"]["path"], "/");
         $fname = $folder . "/uilogger." . date("YmdH") . "0000";
         // create folder if not already there
         if (file_exists($folder) == false) {
             mkdir($folder, 0777);
         }
         $file_exist = false;
         if (file_exists($fname) == false) {
             $file_exist = is_writable($folder) && touch($fname);
         } else {
             $file_exist = true;
         }
         if ($file_exist && is_writable($fname)) {
             file_put_contents($fname, $file_msg, FILE_APPEND);
         }
     }
     $timestats = array("page" => any($webapp->components->pagecfg["pagename"], $webapp->request["path"]), "total" => Profiler::GetTime("WebApp"));
     if (($time = Profiler::GetTime("QPMWrapper:Query()")) != NULL) {
         $timestats["qpm"] = $time;
     }
     if (($time = Profiler::GetTime("QPMThriftWrapper:Query()")) != NULL) {
         $timestats["qpm"] += $time;
     }
     if (($time = Profiler::GetTime("QPMWrapper:Query() - first byte")) != NULL) {
         $timestats["qpmfirstbyte"] = $time;
     }
     if (($time = Profiler::GetTime("DBWrapper:Query()")) != NULL) {
         $timestats["db"] = $time;
     }
     if (($time = Profiler::GetTime("WebApp::TimeToDisplay")) != NULL) {
         $timestats["firstbyte"] = $time;
     }
     if (($time = Profiler::GetTime("WebApp::Display() - Conteg")) != NULL) {
         $timestats["output"] = $time;
     }
     if (($time = Profiler::GetTime("Conteg::compress")) != NULL) {
         $timestats["compress"] = $time;
     }
     if (($time = Profiler::GetTime("Postprocessing")) != NULL) {
         $timestats["postprocessing"] = $time;
     }
     DataManager::Query("stats.default.blah:nocache", "www.timing.total", $timestats);
     $data = DataManager::singleton();
     if ($data) {
         $data->Quit();
         // shutdown to make sure sockets are flushed
//.........这里部分代码省略.........
开发者ID:ameyer430,项目名称:elation,代码行数:101,代码来源:logger.php

示例4: testDelete

 /**
  * Test deleting all data from a table
  *
  * @dataProvider providerOfTables
  */
 public function testDelete($table)
 {
     $q = DataManager::QueryDelete($table["keyprefix"] . ".select.all", $table["name"]);
     $this->assertTrue($q, "Delete all rows from '{$table["name"]}'");
     $qcount = DataManager::Query($table["keyprefix"] . "count", "SELECT COUNT(*) AS cnt FROM {$table["name"]}");
     $this->assertEquals($qcount->rows[0]->cnt, 0, "Check no rows still exist in '{$table["name"]}'");
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:12,代码来源:datamanager_test.php


注:本文中的DataManager::Query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。