Brimbox Logo Brimbox Version 2.3.4 Released

process_json>>

Method to access the json_table either creating, getting, updating or inserting a JSON entry. This function will create a JSON entry if it does not exist.

Class: bb_database, called as $main

File: bb_database.php (php)

Declaration:

function process_json($con, $lookup, $arr = array())

Usage:

$main->process_json($con, $lookup, $arr);

Action: This function has 4 options.

  • If $arr is not populated and the JSON entry exists it returns the JSON value in array format
  • If $arr is not populated and the JSON entry does NOT exist it creates an entry and returns an empty array
  • If $arr is populated and the JSON entry exists it updates the JSON entry
  • If $arr is populated and the JSON entry does NOT exist it creates and populates a new JSON entry.

Result: Returns the array supplied if $arr is populated. If not populated, will return the value in the database entry or an empty array.

Note: If you wish to update or get a value only if the value already exists use update_json or get_json

Parameter: $con (database connector)
Valid database connection.

Parameter: $lookup (string)
Key used to find JSON row for updating in the database.

Parameter: $arr (array)
Valid PHP array to be converted to JSON and stored in database.

v2.3+

Updated: 2016-12-29