JCORE provides a data service layer that is able to interact with multiple data stores and multiple types of data stores from RDBMS to NoSQL through a single data API with a standard "CRUD" interface as well as an option for "raw" interaction. The data API instantiates data base connector classes as defined through a common interface, see: class [sequence] diagram example.
In the MySQL example the connector class is instantiated as needed based on the configuration settings in CONFIG/SERVICE/DATA.ini. See [DATA CONFIGURATION] for more details.
Data operations are performed through 1 of 5 methods of the global DATA_API object: create, retrieve, update, delete, raw. Each of the first 4 operations will return extended data from the query (depending on the DBMS) i.e. the insert id in the case of MySQL with a "create" operation or any errors if they occur.
The data API does not abstract queries or the query language in any capacity. I the case of RDBMS data stores use POS, native "Plain Old SQL" of the data store.
$result = $GLOBALS["DATA_API"]->retrieve(
$DSN='Data Store Name', see: [DATA CONFIGURATION]
$query, a query string
$args=array( *extended arguments *
'returnArray' => true
)
);
Was provisioned to keep the function signature small and allow for secondary operations like write through cache. Setting the value returnArray to true will automatically transform the result set into an array.
returns the following values in the result array from a "create" operation
$resultArray["INSERT_ID"] = mysql_insert_id($connection); $resultArray["AFFECTED_ROWS"] = mysql_affected_rows($connection); $resultArray["INFO"] = mysql_info($connection);
if TRUE the result is returned as a PHP array
returns the following values in the result array from a "update" operation
$resultArray["AFFECTED_ROWS"] = mysql_affected_rows($connection); $resultArray["INFO"] = mysql_info($connection);
returns the following values in the result array from a "delete" operation
$resultArray["AFFECTED_ROWS"] = mysql_affected_rows($connection); $resultArray["INFO"] = mysql_info($connection)
returns the raw result of the query
Wiki: DATA CONFIGURATION
Wiki: Quick Start Guide
Anonymous