コード例 #1
0
ファイル: Host.php プロジェクト: ncsuwebdev/otframework
 public function saveAttribute(Ot_Var_Abstract $var, $hostParentId, $attributeId)
 {
     $model = new Ot_Model_DbTable_CustomAttributeValue();
     $where = $model->getAdapter()->quoteInto('hostParentId = ?', $hostParentId) . ' AND ' . $model->getAdapter()->quoteInto('hostKey = ?', $this->getKey()) . ' AND ' . $model->getAdapter()->quoteInto('attributeId = ?', $attributeId);
     $thisVar = $model->fetchAll($where);
     $data = array('hostParentId' => $hostParentId, 'hostKey' => $this->getKey(), 'attributeId' => $attributeId, 'value' => $var->getRawValue());
     if ($thisVar->count() == 0) {
         $model->insert($data);
     } else {
         $model->update($data, $where);
     }
 }