Hi guys.
In my class I have a constructor. The constructor is run as soon
as the class is initiated (obviously 😉 ). This constructor will pull
out the row from the database via a id, so that we can update or
delete with functions that follow after the constructor.
This might sound stupid to most, but is there a way with in the
constructor to pass a null or empty variable, to a different
function, before the construct release that the id is empty and spits out a error.
The purpose of this would be to insert a new category.
class category extends dbConnect
{
// properties here
function category($category_id=0)
{
//setup the databse connection
$this->dbConnect();
if($this->dbConnect == false){
return($this->error = "Connection Failed.");
}
//no more than 20 words
$array = explode(" ", $_POST['category_desc']);
if(count($array) >= 20) {
return($this->error = "No more than 20 words please.");
exit;
}else{
$this->catgory_desc = implode(" ", $array);
}
//********* I would like the code to be evaluated here******** \\
// ========== some like this maybe ================
if(empty($_POST['category_id']) )
{
// send me to the new insert function
}