コード例 #1
0
function leer_cuotas($dbhandler)
{
    $query = "SELECT * FROM Cuota";
    $table = $dbhandler->query($query);
    $result = array();
    if ($table->num_rows > 0) {
        // output data of each row
        while ($row = $table->fetch_assoc()) {
            $cuota = new Cuota();
            $cuota->read_cuota($row);
            $result[] = $cuota;
        }
    } else {
        echo "no results";
    }
    return $result;
}
コード例 #2
0
<?php

/**
 * Insertar una nueva cuota en la base de datos
 */
require 'Cuota.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Decodificando formato Json
    $body = json_decode(file_get_contents("php://input"), true);
    // Insertar credito
    $retorno = Cuota::insert($body['idCuota'], $body['numero'], $body['fecha'], $body['valor'], $body['idCredito'], $body['pendiente']);
    if ($retorno) {
        // Código de éxito
        print json_encode(array('estado' => '1', 'mensaje' => 'Creación exitosa'));
    } else {
        // Código de falla
        print json_encode(array('estado' => '2', 'mensaje' => 'Creación fallida'));
    }
}