JSONDataSource

class JSONDataSource
setSchema($schema)

Set the Schema for the DataSource. Schema is an array of fields and the types, options associated with them

Example :: array ( ‘FieldName’ => array(‘type’ => ‘text’), ‘FieldName2’ => array(‘type’ => ‘number’) );

Parameters:
  • $schema (array) – Schema for the DataSource
setDataObjectPath($dataObjPath)

If your JSON data is nested deeper than the root level, you can specify that by setting the data object path. So for example, if your JSON string is

{

‘comment’: ‘Accessed on 3-1-2013’, ‘data_container’: { ‘description’: ‘Contents of our data’, ‘data’: { // the actual data you want } } }

Then the data object path is data_container.data

Parameters:
  • $dataObjPath (string) –
setUrl($url)

Set the URL from which the JSON string will be loaded

Parameters:
  • $url (string) –
setFilePath($path)

If you are loading from a JSON file on your server, then provide the full path to the file.

Parameters:
  • $path (string) –
setPostData($postData)

Set the data to be sent along with a POST request. The POST data should be an associative array.

Parameters:
  • $postData (array) –
setHeaders($headers)

Set the custom headers to the request. Pass the headers as a key-value pair.

Parameters:
  • $headers (array) –
setMethod($method)

Set the HTTP request method type

Parameters:
  • $method (string) –
setOptions($options)

Set the options for fetching the data.

Parameters:
  • $options (array|RFHttpOptions) –
initialize()

Loads data into the internal database. This is an internal method.

forceCacheOverWrite()

Even if a cache is available, overwrite it.,

configureCaching($caching)

Configure the caching, by passing an array with the following keys (both optional)

  • enabled => true/false - whether caching is enabled
  • cacheDuration => number of seconds before data is refreshed
Parameters:
  • $caching (array) – Array containing caching parameters
enableCaching()

Enables caching

cacheExists()

Check if a cache exists for the current datasource

setSQLSource($source)

Set the SQL source from which the data is seeded.

Parameters:
  • $source (string) –

Start building interactive, mobile-friendly Dashboards in PHP. See DemosDownload