I am having a little problem with the following code:
<?php
class appointments
{
private $conn;
function __construct($conn)
{
$this->conn = $conn;
}
function usercompany($uid)
{
return $this->conn->getone("SELECT company FROM signup WHERE UID = '".$uid."'");
}
function hastemplate($uid)
{
return $this->conn->getone("SELECT COUNT(parentid) FROM appointments_templates WHERE parentid = '$uid'");
}
function gettemplate($uid)
{
if($this->hastemplate($uid)){
return $this->conn->getrow("SELECT * FROM appointments_templates WHERE parentid = '" . $uid . "'");
} else {
$appointment_template = 'This is a reminder to let you know that you have an appointment on {appointment} at '. $this->usercompany($uid);
$sql = "INSERT INTO appointments_templates SET parentid = '" . $uid . "', content = '" . $appointment_template . "'";
$this->conn->execute($sql);
return $this->gettemplate($uid);
}
}
}
?>
When I call usercompany($uid) by itself I get a correct result which is the users company. However when I call gettemplate($uid) the new template gets added to the database but without the results of usercompany($uid). Am I doing something wrong?
Edit: Regarding the INSERT syntax: http://milov.nl/2836
To recap: Issue is not that its not getting added to the database but rather than getting inserted as "This is a reminder to let you know that you have an appointment on {appointment} at XYZ Inc." its getting added as "This is a reminder to let you know that you have an appointment on {appointment} at "