Looking... can’t find it though. Can you point me in the right direction?
Here’s what I’m trying to do:
function setTV($tvname, $value, $docid="") {
if($tvname== "") return false;
if($docid == "") $docid = $this->documentIdentifier;
//get id of tv
$result=$this->db->select("id", $this->getFullTableName("site_tmplvars"), "name = '". $tvname . "'");
if (!$result) return false;
$row=$this->fetchRow($result);
$rows_affected = $this->db->update("value='" . $value . "'", $this->getFullTableName("site_tmplvar_contentvalues") , "tmplvarid=".$row['id']." AND contentid=".$docid);
if ($rows_affected == 0) {
$fields = array(
"tmplvarid" => $row['id'],
"contentid" => $docid,
"value" => $value
);
$rows_affected = $this->db->insert($fields, $this->getFullTableName("site_tmplvar_contentvalues"));
}
return $rows_affected;
}
When you first create a page there are no TV values stored in the database so the update function doesn’t do anything. So... I’m trying to say if the number of affected rows is zero, then do an insert. For some reason this part is failing:
if ($rows_affected == 0) {
Any idea why?