This is my first foray into writing classes in any language. I’m trying to be a better programmer and want to make sure that the way I’m coding is considered ‘kosher’ or best practice.
Would anyone mind looking over this class I wrote and giving me any pointers as to where I could improve it?
<?php
class TableField {
private $name;
private $input;
}
class ProductField extends TableField {
public $perishable;
public function setProductName($product_name){
$this->name = $product_name;
}
public function setProductPerishable($product_perishable){
$this->perishable = $product_perishable;
}
public function addProduct(){
global $con;
global $db_name;
mysql_select_db($db_name, $con);
mysql_query("INSERT INTO products (name, perishable) VALUES ('$this->name', '$this->perishable')");
echo "Product Added";
echo $this->name;
echo $this->perishable;
echo $db_name;
mysql_close($con);
}
}
?>