本文整理汇总了PHP中DataManager::QueryInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP DataManager::QueryInsert方法的具体用法?PHP DataManager::QueryInsert怎么用?PHP DataManager::QueryInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataManager
的用法示例。
在下文中一共展示了DataManager::QueryInsert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInsert
/**
* Test insertion of data into table
*
* @dataProvider providerOfTables
*/
public function testInsert($table)
{
for ($i = 1; $i <= count($table["rows"]); $i++) {
$q = DataManager::QueryInsert($table["keyprefix"] . ".testinsert", $table["name"], $table["rows"][$i - 1]);
$this->assertEquals($q, $i, "Number of rows in '{$table["name"]}' is {$q} after {$i} inserts");
}
}
示例2: 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
//.........这里部分代码省略.........
示例3: create_new_persist_record
/**
* Create a new persist record in the userdata.usersssion table
*/
protected function create_new_persist_record($force = false)
{
// if bot, don't create a db record
if (function_exists("isBot") && isBot()) {
return;
}
// insert a record into userdata.usersession
if ($force || !empty($_SESSION["persist"])) {
$_SESSION["persist"]["has_db_record"] = true;
$pdata_serialize = serialize($_SESSION["persist"]);
$ip = $_SERVER['REMOTE_ADDR'];
Logger::Notice("Creating session in database");
$result = DataManager::QueryInsert($this->sessionsource . "#{$this->fluid}", $this->sessiontable, array($this->fluid => array("fl_uid" => $this->fluid, "data" => $pdata_serialize, "ip_addr" => $ip)));
// set the $_SESSION
$this->has_db_record = true;
}
}