Hi all,
I am putting together a CRUD. I have read through tutorials, and references.
Just wanted to see if i was on the right track:
<?php
// root -> /classLib/CRUD/CRUD
spl_autoload_extensions(".php");
spl_autoload_register();
use classLib\database\database_Connection as DB;
class CRUD {
private $id;
#__construct to be extended
public function __construct($id=null){
$this->id = $id;
#__construct to be extended
}
public function save()
{
try{
$sql = "";
$q = DB::get()->prepare($sql);
$q->execute(array());
}
catch (Exception $e){
print "Error: " . $e->getMeasage();
}
}
public function update()
{
}
public function delete()
{
try{
$sql = "DELETE FROM [table to be clarified] WHERE id=:id";
$q = DB::get()->prepare($sql);
$q->bindValue(':id', $this->id, PDO::PARAM_INT);
$q->execute();
}
catch (Exception $e){
print "Error!: " . $e->getMessage();
}
}
// End of class
}
?>