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


PHP MySQL::runQuery方法代码示例

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


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

示例1: recalWorkers

 public static function recalWorkers()
 {
     $mysql = new MySQL();
     $rs = $mysql->runQuery("select count(id) as cnt, frequency from monitors where active=1 group by frequency;");
     $workers = 0.0;
     while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
         $workers += (double) $row['cnt'] / (double) $row['frequency'];
     }
     $workers = (int) ceil($workers) * 60;
     $mysql->runQuery("update settings set cronIterations={$workers};");
     $mysql->close();
 }
开发者ID:laiello,项目名称:phpmonitoring,代码行数:12,代码来源:Settings.class.php

示例2: runPlugin

 public function runPlugin($input = array())
 {
     $output = Plugin::$output;
     ///set defaults for all output
     $t = new Timer();
     $t->start();
     try {
         $mysql = new MySQL($input['mysqlConnection']);
         $rs = $mysql->runQuery($input['testQuery']);
         if ($row = mysql_fetch_array($rs, MYSQL_NUM)) {
             $output['currentStatus'] = 1;
             $output['returnContent'] = "All normal\n" . $row[0];
             $output['measuredValue'] = $row[0];
         } else {
             $output['currentStatus'] = 0;
             $output['returnContent'] = "no results were returned for the query" . $input['testQuery'];
         }
     } catch (Exception $e) {
         $output['currentStatus'] = 0;
         $output['returnContent'] = "Query {$input['testQuery']} errored:\n" . $e->getMessage();
     }
     $output['responseTimeMs'] = (int) $t->stop();
     return $output;
 }
开发者ID:laiello,项目名称:phpmonitoring,代码行数:24,代码来源:MySQL.plugin.php

示例3: MySQL

<tr>
<td>
<?php 
$id = array_key_exists('id', $_GET) ? (int) $_GET['id'] : 0;
$del = array_key_exists('del', $_GET) ? (int) $_GET['del'] : 0;
$copy = array_key_exists('cpy', $_GET) ? (int) $_GET['cpy'] : 0;
$name = array_key_exists('name', $_POST) ? $_POST['name'] : '';
$frequency = array_key_exists('frequency', $_POST) ? (int) $_POST['frequency'] : 60;
//60 seconds
$notifyAdmin = array_key_exists('notifyAdmin', $_POST) ? (int) $_POST['notifyAdmin'] : 1;
$pluginType = array_key_exists('pluginType', $_POST) ? $_POST['pluginType'] : '';
$pluginInput = array_key_exists('pluginInput', $_POST) ? $_POST['pluginInput'] : '';
$active = array_key_exists('active', $_POST) ? (int) $_POST['active'] : 1;
$mysql = new MySQL();
if ($copy != 0 && $id != 0) {
    $mysql->runQuery("insert into monitors(name,frequency,notifyAdmin,currentStatus,pluginType,pluginInput,active) (select name,frequency,notifyAdmin,currentStatus,pluginType,pluginInput,active from monitors where id={$id});");
    $id = $mysql->identity;
    Settings::recalWorkers();
    header("Location: setupMonitor.php?id={$id}");
    exit;
} elseif ($name != '' && $id != 0) {
    //update
    $sql = "update monitors \n\t\tset name ='{$name}', \n\t\tfrequency={$frequency}, \n\t\tnotifyAdmin={$notifyAdmin},\n\t\tpluginType='{$pluginType}',\n\t\tpluginInput='" . mysql_real_escape_string($pluginInput, $mysql->mysqlCon) . "', \n\t active={$active} where id = {$id};";
    //echo($sql);
    $mysql->runQuery($sql);
    Settings::recalWorkers();
    header('Location: monitors.php');
    exit;
} elseif ($name != '') {
    //insert
    $sql = "insert into monitors (name,frequency,notifyAdmin,currentStatus,pluginType,pluginInput,active) values(\n\t'{$name}',\n\t{$frequency},\n\t{$notifyAdmin},\n\t1,\n\t'{$pluginType}',\n\t'" . mysql_real_escape_string($pluginInput, $mysql->mysqlCon) . "',\t\n\t{$active}\n\t);";
开发者ID:laiello,项目名称:phpmonitoring,代码行数:31,代码来源:setupMonitor.php

示例4: MySQL

<table class="sortable" width="100%" border="0" cellpadding="1" cellspacing="2">
<tr class="sub">
<th align=center>Monitor</td>
<th align=center>Plugin</td>
<th align=center>Frequency</td>
<th align=center>Status</td>
<th align=center>Last Run</td>
<th align=center>Last Error</td>
<th align=center>Active</td>
<th align=center>Notices</td>
<th align=center>Reports</td>
</tr>
<!--<tbody class="grey">-->
<?php 
$mysql = new MySQL();
$rs = $mysql->runQuery("\nselect *\nfrom monitors m\norder by active, name;\n");
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
    ?>
<tr class="grey" bgcolor="#dddddd">
<td align="left">&nbsp;&nbsp;<a href="setupMonitor.php?id=<?php 
    echo urlencode($row['id']);
    ?>
"><?php 
    echo htmlspecialchars($row['name']);
    ?>
</a></td>
<td align="left">&nbsp;&nbsp;<?php 
    echo htmlspecialchars($row['pluginType']);
    ?>
</td>
<td align="left">&nbsp;&nbsp;<?php 
开发者ID:laiello,项目名称:phpmonitoring,代码行数:31,代码来源:monitors.php

示例5: MySQL

mysql_free_result($rs);
?>
		</table>
	</fieldset>

	<fieldset class="statField">
		<legend>Current Issues</legend>
		<table class="dashboard" border="0" cellspacing="2" cellpadding="2">
			<tr>
			<td><strong>When</strong></td>
			<td><strong>Monitor</strong></td>
			<td><strong>Measured Value</strong></td>
			</tr>
		<?php 
$mysql = new MySQL();
$rs = $mysql->runQuery("\nselect min(l.dateTime) as failureDateTime, l.measuredValue, m.name\nfrom monitors m \n        inner join (\n                select max(id) as id, monitorId\n                from logging\n                where status = 1\n                group by monitorId\n        ) le on le.monitorId = m.id\n        inner join logging l on m.id = l.monitorId and le.id < l.id\n\nwhere m.currentStatus = 0 and l.status = 0\ngroup by m.name\norder by min(l.dateTime) desc limit 50;\n\t\t");
$none = true;
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
    $none = false;
    $whenText = Utilities::timeDiffString($row['failureDateTime']);
    echo "<tr>";
    echo "<td>{$row['failureDateTime']} - ({$whenText})</td>";
    echo "<td>" . htmlentities($row['name']) . "</td>";
    echo "<td>" . $row['measuredValue'] . "</td>";
    echo "</tr>";
}
if ($none) {
    echo "<tr><td colspan=3>none</td></tr>";
}
mysql_free_result($rs);
?>
开发者ID:laiello,项目名称:phpmonitoring,代码行数:31,代码来源:dashboard.php

示例6: Time

echo $id;
?>
 log</td>
</tr>
</thead>

<tr class="sub">
<td align=center>Event Time</td>
<td align=center>Status</td>
<td align=center>Response Time(ms)</td>
<td align=center>Measured Value</td>
</tr>
<tbody class="grey">
<?php 
$mysql = new MySQL();
$rs = $mysql->runQuery("\nselect *\nfrom logging\nwhere monitorId = {$id}\norder by dateTime desc limit 2000;\n");
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
    ?>
<tr bgcolor="#dddddd">
<td align="left">&nbsp;&nbsp;<?php 
    echo $row['dateTime'];
    ?>
</td>
<td align="left">&nbsp;&nbsp;<span class="<?php 
    if ($row['status'] == 1) {
        echo 'green';
    } else {
        echo 'red';
    }
    ?>
"><?php 
开发者ID:laiello,项目名称:phpmonitoring,代码行数:31,代码来源:monitorLog.php

示例7: MySQL

<body onload="setTimeout(function() { window.scrollTo(0, 1) }, 100);">
<h1>Current Issues</h1>
<ul>
<?php 
$mysql = new MySQL();
$rs = $mysql->runQuery("\nselect name, lastError\nfrom monitors \nwhere active = 1 and currentStatus = 0\norder by lastError desc;\n\t\t");
$none = true;
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
    $none = false;
    $whenText = Utilities::timeDiffString($row['lastError']);
    echo '<li><span>' . $row['name'] . ' (' . $whenText . ')</span></li>';
}
if ($none) {
    echo '<li><span>no current issues</span></li>';
}
echo '</ul>';
echo '<h1>Previous Issues</h1>';
echo '<ul>';
mysql_free_result($rs);
$mysql = new MySQL();
$rs = $mysql->runQuery("\nselect name, lastError\nfrom monitors \nwhere active = 1 and currentStatus = 1\norder by lastError desc limit 10;\n\t\t");
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
    $whenText = Utilities::timeDiffString($row['lastError']);
    echo '<li><span>' . $row['name'] . ' (' . $whenText . ')</span></li>';
}
mysql_free_result($rs);
?>
</ul>
</body>
</html>
开发者ID:laiello,项目名称:phpmonitoring,代码行数:30,代码来源:dashboardIphone.php

示例8: or

 $notifyAdmin = $row['notifyAdmin'];
 $mysql->runQuery("update monitors set lastRun=now() where id = {$id};");
 $mysql->runQuery("UNLOCK TABLES;");
 $mysql->close();
 //echo("UNLOCKED\n");
 $pluginClass = $pluginType . 'Plugin';
 //run pluggin
 class_exists($pluginClass, false) or (include './plugins/' . $pluginType . '.plugin.php');
 $input = Settings::parseIniString($pluginInput);
 eval('$inst = new ' . $pluginClass . '; $output = $inst->runPlugin($input);');
 echo date('Y-m-d H:i:s') . "\t{$pluginType}\t{$id}\t{$name}\tStarted\n";
 $mysql = new MySQL();
 $t = new Timer();
 $t->start();
 $sql = sprintf('update monitors set currentStatus = %d where id = %d;', $output['currentStatus'], $id);
 $mysql->runQuery($sql);
 if ($output['currentStatus'] == 0) {
     $mysql->runQuery("update monitors set lastError=now() where id = {$id};");
 }
 //notify anyone?
 $rs = $mysql->runQuery("select * from logging where monitorId = {$id} order by dateTime desc limit 1;");
 if ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
     $previousStatus = $row['status'];
 } else {
     $previousStatus = 0;
 }
 //echo("prev: $previousStatus  - current: $output[currentStatus]\n");
 if ($notifyAdmin == 1 && $previousStatus != $output['currentStatus']) {
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->Host = $settings['smtpServer'];
开发者ID:laiello,项目名称:phpmonitoring,代码行数:31,代码来源:phpMonitorCron.php


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