/** * */ public function getAttributeValues() { if (!$this->getPrimaryKey()) { return null; } $o_db = $this->getDb(); $qr_attrs = $o_db->query("\n\t\t\tSELECT *\n\t\t\tFROM ca_attribute_values cav\n\t\t\tINNER JOIN ca_metadata_elements AS cme ON cme.element_id = cav.element_id\n\t\t\tWHERE\n\t\t\t\tcav.attribute_id = ?\n\t\t", (int) $this->getPrimaryKey()); $o_attr = new Attribute($this->getFieldValuesArray()); while ($qr_attrs->nextRow()) { $va_raw_row = $qr_attrs->getRow(); $o_attr->addValueFromRow($va_raw_row); } return $o_attr->getValues(); }
/** * Return values for currently loaded attribute. * * @param array $pa_options Options include: * returnAs = what to return; possible values are: * values = an array of attribute values [Default] * attributeInstance = an instance of the Attribute class loaded with the attribute value(s) * count = the number of values in the attribute * * @return mixed An array, instance of class Attribute or an integer value count depending upon setting of returnAs option. Returns null if no attribute is loaded. */ public function getAttributeValues($pa_options = null) { if (!$this->getPrimaryKey()) { return null; } $o_db = $this->getDb(); $qr_attrs = $o_db->query("\n\t\t\tSELECT *\n\t\t\tFROM ca_attribute_values cav\n\t\t\tINNER JOIN ca_metadata_elements AS cme ON cme.element_id = cav.element_id\n\t\t\tWHERE\n\t\t\t\tcav.attribute_id = ?\n\t\t", (int) $this->getPrimaryKey()); $o_attr = new Attribute($this->getFieldValuesArray()); while ($qr_attrs->nextRow()) { $va_raw_row = $qr_attrs->getRow(); $o_attr->addValueFromRow($va_raw_row); } switch ($vs_return_as = caGetOption('returnAs', $pa_options, null)) { case 'attributeInstance': return $o_attr; break; case 'count': return sizeof($o_attr->getValues()); break; case 'values': default: return $o_attr->getValues(); break; } }