Server : Apache System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64 User : apache ( 48) PHP Version : 8.0.28 Disable Function : NONE Directory : /var/www/html/mmishra/erp-19-12-2019/models/ |
<?php
class testModel extends erpModel {
public function __construct() {
parent::__construct();
$this->pdo->query($this->db);
}
//***********************************************************************
//* test sql functions *
//***********************************************************************
function saveSample($myName, $myEmail) {
if ($this->pdo->query("SELECT * FROM " .$this->tableID. " WHERE rowID=" .$this->tupleID)->rowCount()) {
$this->sqlStmt = "UPDATE " .$this->tableID. " SET myName='$myName',myEmail='$myEmail'
WHERE rowID=" .$this->tupleID;
$this->pdo->exec($this->sqlStmt);
} else{
$this->sqlStmt = "INSERT INTO " .$this->tableID. "(myName,myEmail)
value('$myName','$myEmail')";
$this->pdo->exec($this->sqlStmt);
$this->tupleID = $this->pdo->lastInsertId();
}
}
function getSample($rowID) {
if ($rowID) {
$this->sqlStmt = $this->pdo->query("SELECT * FROM erp_test.test_samples WHERE rowID=$rowID");
return $this->sqlStmt->fetch(PDO::FETCH_ASSOC);
}
}
function listSamples() {
$this->sqlStmt = $this->pdo->query("SELECT * FROM erp_test.test_samples ORDER BY myName");
return $this->sqlStmt->fetchAll(PDO::FETCH_ASSOC);
}
}
?>