My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
DataTableResult  
Represents a set of results returned from a DataTable query.
Autogenerated
Updated Jan 13, 2010 by innovat...@gmail.com

note: this page is automatically generated from embedded documentation in the PHP source.

Overview

Constructors

Methods

  • num_fields - Returns the number of fields in the result set.
  • num_rows - Returns the number of rows in the result set.
  • result - Returns the query result as an array of objects, or an empty array on any failure.
  • result_array - Returns the query result as an array of associative arrays, or an empty array on any failure.
  • row
  • row_array - Returns an associative array containing a single result row.
  • rowdata - Returns an associative array containing metadata about the values in the specified row.
  • to_string - Returns a tabular string representation of the results.

Constructor Detail

DataTableResult

public DataTableResult(mixed data, mixed uri)

Method Detail

num_fields

public void num_fields()

Returns the number of fields in the result set.

num_rows

public void num_rows()

Returns the number of rows in the result set.

result

public void result()

Returns the query result as an array of objects, or an empty array on any failure. Each field in the original query is mapped to an object variable.

For example:

 $dt = new DataTable('http://api.talis.com/stores/mystore');
 $dt->map('http://xmlns.com/foaf/0.1/name', 'name');
 $dt->map('http://xmlns.com/foaf/0.1/nick', 'nick');
 $dt->select('name,nick')->limit(10);
 $res = $dt->get();
 foreach ($res->result() as $row) {
    echo $row->name;
    echo $row->nick;
 }
 

result_array

public void result_array()

Returns the query result as an array of associative arrays, or an empty array on any failure. The keys and values of the associative array correspond with the fields and values in the results.

For example:

 $dt->select('name,nick')->limit(10);
 $res = $dt->get();
 

foreach ($res->result_array() as $row) { echo $row['name']; echo $row['nick']; }

row

public void row(mixed index)

row_array

public void row_array(mixed index)

Returns an associative array containing a single result row. The $index parameter is optional and defaults to zero.

rowdata

public void rowdata(mixed index)

Returns an associative array containing metadata about the values in the specified row. The array keys correspond to field names and the values to another associative array containing the metadata for that field's value. The $index parameter is optional and defaults to zero.

The following metadata keys are available:

  • type - the type of the field's value, one of "uri", "bnode" or "literal"
  • datatype - the datatype of a literal value, or null if no datatype was detected
  • lang - the language code of a literal value, or null if no language was detected
For example:

 $dt->select('name,nick')->limit(10);
 $res = $dt->get();
 $rowdata = $res->rowdata(5);
 echo $rowdata['name']['type'];
 echo $rowdata['name']['lang'];
 echo $rowdata['name']['datatype'];
 

to_string

public void to_string()

Returns a tabular string representation of the results.

Generated by PHPDoctor 2RC2


Sign in to add a comment
Powered by Google Project Hosting