コード例 #1
0
 /**
  * @return Connection
  */
 public function getConnection()
 {
     if (!$this->connection) {
         $this->connection = Database::connection();
     }
     return $this->connection;
 }
コード例 #2
0
 public function delete()
 {
     $db = Database::connection();
     $db->Execute('delete from AttributeFormsAttributeValues where afID = ? and akID = ? and avID = ?', array($this->item->getID(), $this->attributeKey->getAttributeKeyID(), $this->getAttributeValueID()));
     // Before we run delete() on the parent object, we make sure that attribute value isn't being referenced in the table anywhere else
     $num = $db->GetOne('select count(avID) from AttributeFormsAttributeValues where avID = ?', array($this->getAttributeValueID()));
     if ($num < 1) {
         parent::delete();
     }
 }
コード例 #3
0
 public function setAttributes($attributes)
 {
     if (is_array($attributes)) {
         $db = Database::connection();
         $db->Execute('DELETE FROM AttributeFormTypeAttributes WHERE aftID = ?', array($this->getID()));
         $sortOrder = 1;
         foreach ($attributes as $akID) {
             $data = ['aftID' => $this->getID(), 'akID' => $akID, 'sortOrder' => $sortOrder++];
             $db->insert('AttributeFormTypeAttributes', $data);
         }
     }
 }
コード例 #4
0
 public function delete()
 {
     parent::delete();
     $db = Database::connection();
     $r = $db->Execute('select avID from AttributeFormsAttributeValues where akID = ?', array($this->getAttributeKeyID()));
     while ($row = $r->FetchRow()) {
         $db->Execute('delete from AttributeValues where avID = ?', array($row['avID']));
     }
     $db->Execute('delete from AttributeFormsAttributeValues where akID = ?', array($this->getAttributeKeyID()));
 }
コード例 #5
0
 public function deleteValue()
 {
     $db = Database::connection();
     $db->Execute('delete from atAttributeSwitcher where avID = ?', array($this->getAttributeValueID()));
 }
コード例 #6
0
 public function getAttributeValueObject($ak, $createIfNotFound = false)
 {
     $db = Database::connection();
     $av = false;
     $v = array($this->getID(), $ak->getAttributeKeyID());
     $avID = $db->GetOne("select avID from AttributeFormsAttributeValues where afID = ? and akID = ?", $v);
     if ($avID > 0) {
         $av = AttributeFormValue::getByID($avID);
         if (is_object($av)) {
             $av->setAttributeForm($this);
             $av->setAttributeKey($ak);
         }
     }
     if ($createIfNotFound) {
         $cnt = 0;
         // Is this avID in use ?
         if (is_object($av)) {
             $cnt = $db->GetOne("select count(avID) from AttributeFormsAttributeValues where avID = ?", $av->getAttributeValueID());
         }
         if (!is_object($av) || $cnt > 1) {
             $av = $ak->addAttributeValue();
         }
     }
     return $av;
 }