Beispiel #1
0
/**
 * function saveScheda
 * 
 */
function saveScheda()
{
    try {
        $params = fillParams();
        $dao = new DAOScheda();
        $scheda = new Scheda();
        SchedaMapper::map($scheda, $params);
        //echo $scheda;
        $errors = SchedaValidator::validate($scheda);
        if (empty($errors)) {
            $scheda = $dao->save($scheda);
            echo "done";
        } else {
            var_dump($errors);
            //print_r($errors->getMessage());
            throw new Exception("errore durante il salvataggio ");
        }
    } catch (Exception $ex) {
        throw new Exception($ex);
    }
}
Beispiel #2
0
 /**
  * Get {@link Scheda} by the identifier 'id' found in the URL.
  * @return Scheda {@link Scheda} instance
  * @throws NotFoundException if the param or {@link Scheda} instance is not found
  */
 public static function getSchedaByGetId()
 {
     $id = null;
     try {
         $id = self::getUrlParam('id');
     } catch (Exception $ex) {
         throw new NotFoundException('Nessuna scheda trovata');
     }
     if (!is_numeric($id)) {
         throw new NotFoundException('Nessuna scheda trovata.');
     }
     $dao = new DAOScheda();
     $scheda = $dao->findById($id);
     if ($scheda === null) {
         throw new NotFoundException('Nessuna scheda trovata.');
     }
     return $scheda;
 }
Beispiel #3
0
<?php

ini_set('error_reporting', E_ALL);
require_once '../app/dao/DAOScheda.php';
require_once '../app/model/scheda.php';
require_once '../app/common/utils.php';
require_once '../app/mapper/SchedaMapper.php';
require_once '../app/config/Config.php';
require_once '../app/validation/SchedaValidator.php';
$errors = array();
$scheda = new scheda();
$params = array('ANNO' => 2015, 'APIARIO' => "CATANIA", 'ALVEARE' => 'HIVE2', 'N_API' => 10, 'N_FAVI' => 5, 'SUPERFICIE' => 700, 'MIELE' => 5, 'N_CELLEREALI' => 10, 'N_MELARI' => 5, 'NOTE' => "nessuna nota per questo inserimento scarso", 'DATASCHEDA' => "01-09-2015", 'IDUTENTE' => 1, 'REGINA' => 1, 'IDCOLOREREGINA' => 3, 'DELETED' => 0);
SchedaMapper::map($scheda, $params);
$dao = new DAOScheda();
if (empty($errors)) {
    $scheda = $dao->save($scheda);
    var_dump($scheda);
    echo "ma vediamo";
} else {
    echo 'molto male';
}