Ejemplo n.º 1
0
 /**
  * 
  * Enter description here ...
  */
 public static function getAll()
 {
     $dbh = $GLOBALS['dbh'];
     $result = array();
     $sql = "\n\t\t\tSELECT\n\t\t\t\t* \n\t\t\tFROM \n\t\t\t\t`range`\n\t\t";
     foreach ($dbh->query($sql) as $r) {
         $range = new Range();
         $range->set_id($r['id']);
         $range->set_name($r['name']);
         $result[] = $range;
     }
     return $result;
 }
Ejemplo n.º 2
0
<?php

include_once 'class/range.class.php';
// Insert
if (isset($_POST['insert'])) {
    $range = new Range();
    $range->set_name((string) $_POST['name']);
    Range::save($range);
    die('1');
}
// Update
if (isset($_POST['update'])) {
    $range = new Range();
    $range->set_id((int) $_POST['id']);
    $range->set_name((string) $_POST['name']);
    Range::save($range);
    die('1');
}
// Delete
if (isset($_POST['delete'])) {
    Range::delete((int) $_POST['id']);
    die('1');
}
$ranges = Range::getAll();
$smarty->assign('ranges', $ranges);
$smarty->display('range.tpl');