function html_decode_recursive($data) { if (!is_scalar($data) && $data !== NULL) { foreach ($data as $rk => $rv) { if (!is_scalar($rv) && $data !== NULL) { $data[$rk] = html_decode_recursive($rv); } else { $data[$rk] = html_entity_decode($rv); } } return $data; } return html_entity_decode($data); }
* - query: (string) Set a custom query to the database * - cacheable: (bool) Whether the endpoind results will be cached or not. Default FALSE. * - join: (array) Set the columns that will be joined to current query. * Special notation (assoc array) {key} => {first_col}|{second_col}|{cols_to_fetch} * key: [required] Table name that will be joined * first_col: [required] Value from current table query. * second_col: [required] Value from table that will be joined. * cols_to_fetch: [optional] One or more columns (separated by ",") that will be fetched in the joined column. * - table_alias (string) Set an alias for given table. Useful for hiding real table names from endpoint users. * - before (function) Set a callback function to manipulate query before execution. Must return Database Query. * - after (function) Set a callback function to manipulate data after fetch and before encoding. * * => [Optional] Secured (bool): Defines if endpoint is secured with defined security. * * - All Getter are default unsecured (FALSE). * - All other classes (Poster, Putter, Deleter) are default secured (TRUE). * */ new Getter("users", array("description" => "Get all users", "create_new_table" => TRUE, "modify_existing_table" => TRUE, "columns" => array("first_name|string|200", "last_name|string|200", "group_id|int"), "show" => array("first_name", "last_name", "group_id"), "limit" => "count", "sort" => "group_id|asc", "col_prefix" => "aph_", "cacheable" => FALSE, "join" => array("groups" => "group_id|id|id,group_name,group_desc"), "before" => function ($query) { return $query; }, "after" => function ($result) { return html_decode_recursive($result); })); new Getter("teams", array("description" => "Get all groups", "create_new_table" => TRUE, "modify_existing_table" => TRUE, "columns" => array("group_name|string|100|unique", "group_desc|text", "group_meeting|date"), "limit" => "number", "cacheable" => FALSE, "col_prefix" => "aph_", "table_alias" => "groups")); new Getter("users/:id", array("query" => "SELECT * FROM `api_users` WHERE `id` = %id\$v AND `aph_group_id` = '%group_id\$v'", "columns" => array("group_id"), "cacheable" => TRUE, "join" => array("groups" => "group_id|id"))); new Getter("groups/:id"); new Poster("users/add", array("columns" => array("first_name|string", "last_name|string", "group_id|int"))); new Poster("users/edit/:id", array("columns" => array("first_name", "last_name", "group_id"))); new Poster("groups/create", array("columns" => array("group_name|string|100", "group_desc|text", "group_meeting|date"))); new Poster("groups/edit/:id", array("columns" => array("date"))); new Deleter("users/delete/:id");