\Blackpulp\MinistryPlatformStoredProcedureResult

This class handles interactions with Stored Procedure results.

More specifically, it provides a unified object used to interact with table-based results returned from various MinistryPlatform API calls.

Summary

Methods
Properties
Constants
__construct()
getTableCount()
getTables()
getTable()
getTableKeyValuePair()
getRaw()
getSchema()
No public properties found
No constants found
setTableCount()
setTables()
processTableContents()
processXMLElement()
checkForErrors()
$result
$schema
$table_count
$tables
N/A
No private methods found
No private properties found
N/A

Properties

$result

$result : \SimpleXMLElement

The full raw result.

Type

\SimpleXMLElement

$schema

$schema : \SimpleXMLElement

The XML schema object returned. Not sure if this is useful or not.

.

Type

\SimpleXMLElement

$table_count

$table_count : integer

A simple count of all tables returned in the dataset.

Type

integer

$tables

$tables : array

An array representation of all tables of data returned by the stored procedure.

Type

array

Methods

__construct()

__construct(\SimpleXMLElement  $result) 

Initialize the object

Parameters

\SimpleXMLElement $result

getTableCount()

getTableCount() : integer

Get the number of tables in the current stored procedure result.

Returns

integer

getTables()

getTables() 

Retrieve the tables returned by the Stored Procedure.

getTable()

getTable(integer  $key) : array

Retrieve a single table.

Parameters

integer $key

Returns

array

getTableKeyValuePair()

getTableKeyValuePair(integer  $key) : array

Associative array of values from a Stored Procedure Table.

When a stored procedure table returns an array of arrays, this can be helpful in retrieving only the first two fields of data as a key value pair.

For example, an array that contains a Prefix_ID and Prefix_Name would ideally provide an a value of $prefixes[Prefix_ID] => Prefix_Name. This is precisely what this method will do. Please note that it will ignore and discard any additional fields that may be in the array.

Parameters

integer $key

The array key of the requested stored procedure table.

Returns

array —

A $key->$value array.

getRaw()

getRaw() : \SimpleXMLElement

Get the Raw response object.

Returns

\SimpleXMLElement

getSchema()

getSchema() : \SimpleXMLElement

Get the Schema object.

Returns

\SimpleXMLElement

setTableCount()

setTableCount() 

Set the table count.

setTables()

setTables() 

Parse the XML into a series of arrays.

processTableContents()

processTableContents(\SimpleXMLElement  $contents) : array

Digest the table contents.

Convert XML Element contents into one or more arrays of data.

Parameters

\SimpleXMLElement $contents

Returns

array

processXMLElement()

processXMLElement(\SimpleXMLElement  $element) : array

Process a single Element into an array of elements.

Also detects nested elements and processes those, and handles some data type detection.

Parameters

\SimpleXMLElement $element

Returns

array

checkForErrors()

checkForErrors() 

Error handling for Stored Procedure API calls.

Check to see if the API call returned an error. If so, throw an exception and prevent things form continuing on.