$value) { if (property_exists(get_called_class(), $field)) { if (substr($field, 0, 5) == "vlan_" && !$value) { $model->$field = null; continue; } $model->$field = $value; } } $me = mfValuecache::singleton()->get("me"); if (!$me) { $me = new User(); $me->loadMe(); mfValuecache::singleton()->set("me", $me); } if ($model->create_by === null) { $model->create_by = $me->id; } if ($model->edit_by === null) { $model->edit_by = $me->id; } return $model; } public static function getOne($id) { if (!is_numeric($id) || !$id) { throw new Exception("Invalid number", 400); } $item = []; $db = FronkDB::singleton(); $res = $db->select("Poprackmodulepatch", "*", "id=$id LIMIT 1"); if ($db->num_rows($res)) { $data = $db->fetch_object($res); $item = new Poprackmodulepatch($data); } return $item; } public static function countAllModule($moduleId) { $items = []; $db = FronkDB::singleton(); $sql = "SELECT `id` FROM `Poprackmodulepatch` WHERE `poprackmodule_id`='" . $moduleId . "'"; $res = $db->query($sql); $countrows = $db->num_rows($res); return $countrows; } public static function deletebyPort($moduleId, $port) { $db = FronkDB::singleton(); $sql = "DELETE FROM `Poprackmodulepatch` WHERE `port`='" . $port . "' AND `poprackmodule_id`='" . $moduleId . "'"; $res = $db->query($sql); } public static function updatebyPort($moduleId, $port, $fiberPlanCable_id) { $db = FronkDB::singleton(); $sql = "UPDATE `Poprackmodulepatch` SET fiberPlanCable_id='" . $fiberPlanCable_id . "' WHERE `port`='" . $port . "' AND `poprackmodule_id`='" . $moduleId . "'"; echo $sql . "\n"; $db->query($sql); } public static function updatebyPortRange($moduleId, $startport, $endport, $fiberPlanCable_id) { $db = FronkDB::singleton(); $sql = "UPDATE `Poprackmodulepatch` SET fiberPlanCable_id='" . $fiberPlanCable_id . "' WHERE `port`>='" . $startport . "' AND `port`<='" . $endport . "' AND `poprackmodule_id`='" . $moduleId . "'"; echo $sql . "\n"; $db->query($sql); } public static function clearPort($fiberPlanCable_id) { $db = FronkDB::singleton(); $sql = "UPDATE `Poprackmodulepatch` SET fiberPlanCable_id=NULL WHERE `fiberPlanCable_id`='" . $fiberPlanCable_id . "'"; $db->query($sql); } }