所以,我有这个问题。我正在尽我最大的努力练习面向对象的编程,并且我已经开始使用这个半 OOP 脚本。它是如何工作的,我有一张名为 portal_robot_error 女巫的表,其中包含所有机器人错误。然后我有另一个名为 portal_robot_service 的主表,它是服务的最高级别。连接到这个表我还有 2 个与 portal_robot_service 表链接。这些被称为 portal_service_robot_errorservice 和 portal_service_robot_changeservice 包含服务的详细信息。我希望我已经设法很好地解释了这部分!
这就是我想做的。当用户搜索机器人时,所有错误和所有服务都应以按日期排序的列表结尾。
示例:用户搜索机器人 21。结果:错误 1 - 日期、机器人、位置、错误代码等。错误 2 - 日期、机器人、位置、错误代码等。服务 1 - 日期、机器人、服务类型等。错误 3 -日期、机器人、位置、错误代码等 错误 4 - 日期、机器人、位置、错误代码等...
由于脚本现在只显示错误,我如何在列表中显示服务?
提前致谢!
<?php
elseif(!empty($query) && empty($inDate) && empty($id) && empty($dateLike)) {
$arr = array();
$q = mysql_query("SELECT * FROM portal_robot_error WHERE robot = '$robot'");
while($r = mysql_fetch_object($q)) {
$m = "Robot ".$r->robot;
$s = mysql_query("SELECT * FROM portal_service WHERE service_date >= '$this->lastService' AND service_date <= '$r->date' AND service_module = '$m' AND service_id > '$this->lastId' LIMIT 1");
if(mysql_num_rows($s) > 0) {
echo "SELECT * FROM portal_service WHERE service_date >= '$this->lastService' AND service_date <= '$r->date' AND service_module = '$m' AND service_id > '$this->lastId' LIMIT 1<br />";
$z = mysql_fetch_object($s);
$this->lastId = $z->service_id;
if($z->service_type == "Errorservice") {
$e = mysql_query("SELECT * FROM portal_service_robot_errorservice WHERE service_id = '$z->service_id'");
$f = mysql_fetch_object($e);
$errorservice_track = $f->tracksensor;
$errorservice_gripper = $f->gripper;
$errorservice_cover = $f->cover;
$errorservice_wheel = $f->wheel;
$service_text = "Errorservice HIHIHIHI".$this->lastId;
$service = new Error($this->lastId, $z->service_date, "", "", $z->service_module, "", "", $z->service_type, $z->service_comment, $service_text, "", $z->service_user);
array_push($arr, $service);
}
elseif($z->service_type == "Changeservice") {
$e = mysql_query("SELECT * FROM portal_service_robot_changeservice WHERE service_id = '$z->service_id'");
$f = mysql_fetch_object($e);
$service_text = "Changeservice HIHIHIHI".$this->lastId;
$service = new Error($this->lastId, $z->service_date, "", "", $z->service_module, "", "", $z->service_type, $z->service_comment, $service_text, "", $z->service_user);
array_push($arr, $service);
}
}
else {
$n = new Error($r->error_id, $r->date, $r->stoptime, $r->starttime, $r->robot, $r->rob_status, $r->position, $r->error_code, $r->observation, $r->solution, $r->downtime, $r->user);
array_push($arr, $n);
$this->lastService = $r->date;
}
}
return $arr;
}
?>