本文整理汇总了PHP中Computer::GetComputersByLab方法的典型用法代码示例。如果您正苦于以下问题:PHP Computer::GetComputersByLab方法的具体用法?PHP Computer::GetComputersByLab怎么用?PHP Computer::GetComputersByLab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::GetComputersByLab方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ini_set
<?php
ini_set("display_errors", 1);
if (isset($_GET["lab"]) == false) {
echo "Bad input 1";
exit;
}
$lab_id = $_GET["lab"];
if (preg_match("/^\\d+\$/", $lab_id) == false) {
echo "Bad input 2";
exit;
}
$lab_id = (int) $lab_id;
require_once "../classes/db_connection.php";
require_once "../classes/lab.php";
require_once "../classes/computer.php";
$computers = array();
try {
DBConnection::Connect();
$computers = Computer::GetComputersByLab($lab_id);
DBConnection::Close();
} catch (Exception $ex) {
}
$st = "";
foreach ($computers as $computer) {
$st .= "{\n\t\t\t\t\"id\": " . $computer->ID . ",\n\t\t\t\t\"ip\": \"" . $computer->IP . "\",\n\t\t\t\t\"name\": \"" . $computer->Name . "\",\n\t\t\t\t\"studentID\": " . ($computer->StudentID == null ? "null" : "\"" . $computer->StudentID . "\"") . ",\n\t\t\t\t\"x1\": " . $computer->X1 . ",\n \"y1\": " . $computer->Y1 . ",\n\t\t\t\t\"statusID\": " . $computer->StatusID . "\n\t\t\t},";
}
$st = str_replace("\t", "", substr($st, 0, -1));
header("Content-Type: application/json");
//header("Content-Type: text/plain");
echo "[" . $st . "]";