| Current Path : /var/www/html/mmishra/erp/models/ |
| Current File : /var/www/html/mmishra/erp/models/test_model.php |
<?php
//if (!class_exists($erpModel)) {
require_once __DIR__."/erp_model.php";
//}
class testModel extends erpModel {
public function __construct() {
// mysql connection using PDO
try {
$this->pdo = new PDO('mysql:host=' .DB_SERVER. ';dbname=' .DB_NAME. ';charset=utf8', DB_USER, DB_PASSWD, $options);
$this->pdo->query("use erp_test");
} catch (PDOException $e) {
die("Error!: " . $e->getMessage());
}
}
public function __destruct() {
//print mysql_error();
$this->dbStmt = null;
$this->pdo = null;
}
//***********************************************************************
//* hms Dashboard data *
//***********************************************************************
function saveHello($myname) {
if ($this->pdo->query("SELECT * FROM " .$this->tableID. " WHERE rowID=" .$this->tupleID)->rowCount()) {
$this->sqlStmt = "UPDATE " .$this->tableID. " SET myName='$myname'
WHERE rowID=" .$this->tupleID;
$this->pdo->exec($this->sqlStmt);
} else{
$this->sqlStmt = "INSERT INTO " .$this->tableID. "(myName)
value('$myname')";
$this->pdo->exec($this->sqlStmt);
$this->tupleID = $this->pdo->lastInsertId();
}
}
function listHellos() {
$this->dbStmt = $this->pdo->query("SELECT * FROM erp_test.test_hellos ORDER BY myName");
return $this->dbStmt->fetchAll(PDO::FETCH_ASSOC);
}
}
?>