I have a class where I first do a SQL check to see if some certain data exist and if not then I INSERT a new record.
I'd like to somehow define a variable ($feedback) indicating ive either inserted something or havent - I want to use this var in a callback in my main PHP file (where ive included the class)
My class
class registerVote {
function registerVote(){
}
function init() {
//Define some vars
return true;
}
function save() {
//Sql count query
$res = mysql_query($sql) or die( mysql_error());
$count = mysql_result($res, 0);
//If no records are found then INSERT
if($count < 1){
//Some INSERT query
$feedback = "new";
} else {
$feedback = "old";
}
if($res) {
return $feedback;
}
}
}
My PHP FILE:
include_once ('../class/class_vote.php');
$registerVote = new registerVote();
if($registerVote->init()) {
if($registerVote->save()) {
//Print out my $feedback from the class
if ($feedback == "new") {
echo "new";
} else {
echo "old";
}
}
}
The above naturally doesnt work - so im naturally wondering if im able to achieve what ive tried to illustrate?