function FiberSplice_Add($CableLineA, $fiberA, $CableLineB, $fiberB, $FiberSpliceOrganizer, $NetworkNodeId, $attenuation, $note) { if ($CableLineA == $CableLineB && $fiberA == $fiberB) { return array('error' => 'Сварка волокна само с собой!'); } if ($FiberSpliceOrganizer == '') { return array('error' => 'Выберите кассету!'); } $splice = getSplice($CableLineA, $fiberA, $CableLineB, $fiberB, $NetworkNodeId); if (isset($splice['error'])) { return $res; } if ($splice['count'] > 0) { return array('error' => 'Сварка уже существует!'); } $trans = startTransaction(); $ins['NetworkNode'] = $NetworkNodeId; $ins['FiberSpliceOrganizer'] = $FiberSpliceOrganizer; $ins['attenuation'] = $attenuation; $ins['note'] = $note; $res = OpticalFiberSplice_INSERT($ins); if (isset($res['error'])) { if ($trans) { rollbackTransaction(); } return $res; } $OFS_id = $res['rows'][0]['id']; $res = addOpticalFiberJoin($CableLineA, $fiberA, $OFS_id); if (isset($res['error'])) { if ($trans) { rollbackTransaction(); } return $res; } $res = addOpticalFiberJoin($CableLineB, $fiberB, $OFS_id); if (isset($res['error'])) { if ($trans) { rollbackTransaction(); } return $res; } return $trans ? commitTransaction() : 1; }
function cancelOrder($link, $orderId, $customerId) { $stmt = prepareQuery($link, 'DELETE FROM waiting_orders WHERE order_id=? AND customer_id=?'); if (is_null($stmt)) { rollbackTransaction($link); return null; } $result = null; if (!mysqli_stmt_bind_param($stmt, 'ii', $orderId, $customerId)) { logMysqlStmtError(CANNOT_BIND_SQL_PARAMS, $stmt); rollbackTransaction($link); } else { if (!executeStatement($stmt)) { rollbackTransaction($link); } else { $result = mysqli_stmt_affected_rows($stmt) !== 0; } } mysqli_stmt_close($stmt); return $result; }