public function EasyRdf_Graph::add in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php \EasyRdf_Graph::add()
Add data to the graph
The resource can either be a resource or the URI of a resource.
Example: $graph->add("http://www.example.com", 'dc:title', 'Title of Page');
Parameters
mixed $resource The resource to add data to:
mixed $property The property name:
mixed $value The new value for the property:
Return value
integer The number of values added (1 or 0)
4 calls to EasyRdf_Graph::add()
- EasyRdf_Graph::addLiteral in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Graph.php - Add a literal value as a property of a resource
- EasyRdf_Graph::addResource in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Graph.php - Add a resource as a property of another resource
- EasyRdf_Graph::addType in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Graph.php - Add one or more rdf:type properties to a resource
- EasyRdf_Graph::set in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Graph.php - Set a value for a property
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Graph.php, line 918
Class
- EasyRdf_Graph
- Container for collection of EasyRdf_Resources.
Code
public function add($resource, $property, $value) {
$this
->checkResourceParam($resource);
$this
->checkSinglePropertyParam($property, $inverse);
$this
->checkValueParam($value);
// No value given?
if ($value === null) {
return 0;
}
// Check that the value doesn't already exist
if (isset($this->index[$resource][$property])) {
foreach ($this->index[$resource][$property] as $v) {
if ($v == $value) {
return 0;
}
}
}
$this->index[$resource][$property][] = $value;
// Add to the reverse index if it is a resource
if ($value['type'] == 'uri' or $value['type'] == 'bnode') {
$uri = $value['value'];
$this->revIndex[$uri][$property][] = array(
'type' => substr($resource, 0, 2) == '_:' ? 'bnode' : 'uri',
'value' => $resource,
);
}
// Success
return 1;
}