/** * Short description of method getPropertyValuesByLg * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource resource * @param Property property * @param string lg * @return core_kernel_classes_ContainerCollection */ public function getPropertyValuesByLg(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $lg) { $returnValue = null; $options = array('lg' => $lg); $returnValue = new core_kernel_classes_ContainerCollection($resource); foreach ($this->getPropertyValues($resource, $property, $options) as $value) { $returnValue->add(common_Utils::toResource($value)); } return $returnValue; }
/** * Helper to return one property value, since there is no order * if there are multiple values the value to be returned will be choosen by random * * optional parameter $last should NOT be used since it is no longer supported * and will be removed in future versions * * @access public * @author Joel Bout, <*****@*****.**> * @param Property property * @param boolean last * @return core_kernel_classes_Container */ public function getOnePropertyValue(core_kernel_classes_Property $property, $last = false) { $returnValue = null; if ($last) { throw new core_kernel_persistence_Exception('parameter \'last\' for getOnePropertyValue no longer supported'); } $options = array('forceDefaultLg' => true, 'one' => true); $value = $this->getPropertyValues($property, $options); if (count($value)) { $returnValue = common_Utils::toResource(current($value)); } return $returnValue; }
/** * (non-PHPdoc) * @see core_kernel_persistence_ClassInterface::getInstancesPropertyValues() */ public function getInstancesPropertyValues(core_kernel_classes_Class $resource, core_kernel_classes_Property $property, $propertyFilters = array(), $options = array()) { $returnValue = array(); $distinct = isset($options['distinct']) ? $options['distinct'] : false; if (count($propertyFilters) === 0) { $options = array_merge($options, array('like' => false)); } $filteredQuery = $this->getFilteredQuery($resource, $propertyFilters, $options); // Get all the available property values in the subset of instances $query = 'SELECT'; if ($distinct) { $query .= ' DISTINCT'; } $query .= " object FROM (SELECT overq.subject, valuesq.object FROM ({$filteredQuery}) as overq JOIN statements AS valuesq ON (overq.subject = valuesq.subject AND valuesq.predicate = ?)) AS overrootq"; $sqlResult = $this->getPersistence()->query($query, array($property->getUri())); while ($row = $sqlResult->fetch()) { $returnValue[] = common_Utils::toResource($row['object']); } return (array) $returnValue; }