Esempio n. 1
0
    if ($i != 0) {
        echo "|";
    }
    echo M_GetHeader($conn, $identifier, $i);
}
echo "\r\n";
/* Print one row per line, each cell separated by |'s */
for ($j = 0; $j < $rows; $j++) {
    for ($i = 0; $i < $columns; $i++) {
        if ($i != 0) {
            echo "|";
        }
        echo M_GetCellByNum($conn, $identifier, $i, $j);
    }
    echo "\r\n";
}
/*
 * Use M_GetCell instead of M_GetCellByNum if you need a
 * specific column, as the results will allow for position-
 * independent searching of the results. The ordering of
 * returned headers may be different between Monetra versions,
 * so that is _highly_ recommended */
/* Optionally free transaction, though M_DestroyConn() will
 * do this for us */
M_DeleteTrans($conn, $identifier);
/* Clean up and close */
M_DestroyConn($conn);
M_DestroyEngine();
?>

Esempio n. 2
0
 function M_verifyping(&$conn)
 {
     $max_ping_time = 5;
     $blocking = $conn['blocking'];
     M_SetBlocking($conn, false);
     $id = M_TransNew($conn);
     M_TransKeyVal($conn, $id, "action", "ping");
     if (!M_TransSend($conn, $id)) {
         M_DeleteTrans($conn, $id);
         return false;
     }
     $lasttime = time();
     while (M_CheckStatus($conn, $id) == M_PENDING && time() - $lasttime <= $max_ping_time) {
         $wait_time_ms = ($max_ping_time - (time() - $lasttime)) * 1000;
         if ($wait_time_ms < 0) {
             $wait_time_ms = 0;
         }
         if ($wait_time_ms > $max_ping_time * 1000) {
             $wait_time_ms = $max_ping_time * 1000;
         }
         if (!M_Monitor($conn, $wait_time_ms)) {
             break;
         }
     }
     M_SetBlocking($conn, $blocking);
     $status = M_CheckStatus($conn, $id);
     M_DeleteTrans($conn, $id);
     if ($status != M_DONE) {
         return false;
     }
     return true;
 }
 function M_DeleteResponse(&$conn, $id)
 {
     return M_DeleteTrans($conn, $id);
 }
 private function executeRequest($identifier)
 {
     if (!M_TransSend($this->conn, $identifier)) {
         throw new MonetraException(__('Transaction improperly structured.'));
     }
     if (M_ReturnStatus($this->conn, $identifier) === M_SUCCESS) {
         if (M_IsCommaDelimited($this->conn, $identifier)) {
             $csv_string = M_GetCommaDelimited($this->conn, $identifier);
             if ($csv_string === false) {
                 throw new MonetraException(__('Transaction does not exist or is incomplete.'));
             }
             $response = $this->parseCSVResponse($csv_string);
         } else {
             $response = $this->parseKeyValueResponse($identifier);
         }
     } else {
         $response = $this->parseKeyValueResponse($identifier);
     }
     M_DeleteTrans($this->conn, $identifier);
     return $response;
 }