本文整理匯總了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 . "]";