Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
92 righe
2.5 KiB
92 righe
2.5 KiB
<?php |
|
|
|
require_once "IDataClass.php"; |
|
/* |
|
* To change this license header, choose License Headers in Project Properties. |
|
* To change this template file, choose Tools | Templates |
|
* and open the template in the editor. |
|
*/ |
|
|
|
/** |
|
* Description of UTENTI |
|
* |
|
* @author Stefano |
|
*/ |
|
class Object extends DataClass { |
|
|
|
//put your code here |
|
// inserire qui il nome della tabella |
|
|
|
const TABLE_NAME = "NOME_TABELLA"; |
|
/* |
|
* inserire qui le colonne |
|
*/ |
|
public $ID = ""; |
|
|
|
public function __construct($src = null) { |
|
global $con; |
|
if ($src == null) |
|
return; |
|
if (is_array($src)) { |
|
if (isset($src['id']) && $src['id'] > 0) { |
|
$this->_loadAndFillObject($src['id'], self::TABLE_NAME, $src); |
|
} else { |
|
$this->_loadByRow($src, $stripSlashes); |
|
} |
|
} elseif (intval($src)) { |
|
$this->_loadById($src, self::TABLE_NAME, true); |
|
} |
|
} |
|
|
|
public static function LoadDataTable($searchQuery = "", $searchArray = array(), $columnName = array(), $columnSortOrder = array(), $start = 0, $offset = 0) { |
|
|
|
return parent::_loadDataTable(self::TABLE_NAME, $searchQuery, $searchArray, $columnName, $columnSortOrder, $start, $offset); |
|
} |
|
|
|
public function Save() { |
|
global $con; |
|
$vars = get_object_vars($this); |
|
$sql = Utils::prepareQuery(self::TABLE_NAME, $vars); |
|
$queryabi = $con->prepare($sql); |
|
foreach ($vars as $k => $v) { |
|
if ($k == "ID" && $v == 0) |
|
continue; |
|
$queryabi->bindValue(":" . $k, $v); |
|
} |
|
try { |
|
$it = parent::_Save($queryabi); |
|
} catch (Exception $exc) { |
|
$it['descrizioneErrore'] = $exc->getMessage(); |
|
} |
|
return $it; |
|
} |
|
|
|
public function Delete() { |
|
return parent::_Delete(self::TABLE_NAME, "id = " . $this->id); |
|
} |
|
|
|
/** |
|
* Elimina l'oggetto corrente dal database e restituisce TRUE se ha successo |
|
* |
|
* @return bool Risultato booleano dell'operazione |
|
*/ |
|
public function LogicalDelete() { |
|
return parent::_LogicalDelete(self::TABLE_NAME, "id = " . $this->id); |
|
} |
|
|
|
/** |
|
* Funzione per la visualizzazione dei logs |
|
* @param type $record |
|
* @param type $campo |
|
*/ |
|
public function Parse(&$record, $campo = "") { |
|
$props = get_class_vars(get_class($this)); |
|
switch ($campo) { |
|
|
|
default: |
|
array_push($record, array("Campo" => $campo, "Valore" => $this->$campo)); |
|
break; |
|
} |
|
} |
|
|
|
}
|
|
|