progetto201 API
Functions | Variables
planlabels.php File Reference

PLANLABELS: manages plan's labels. More...

Functions

 post_labels ($t_conn_res)
 Inserts/removes label data to the database. More...
 
 get_labels ($t_conn_res)
 Returns labels data. More...
 

Variables

 $response = array("errors" => array())
 Prepare default response array with no errors. More...
 

Detailed Description

PLANLABELS: manages plan's labels.

Client perspective:

Description

This script sets the returned content type to JSON, includes the db_connection.php script

It is used to connect to MySQL and execute basic SELECT queries

and then defines the response array.

Two functions are defined:

 post_labels()

Inserts/removes label data to the database.

 get_labels()

Returns labels data

If the script isn't included it tries to connect to the database, and checks the request method:

When the called function ends the connection to the DB gets terminated, and data (or errors) is collected inside the response array. The response array gets echoed to the client in JSON format

Errors list:

Since
01_01
Author
Stefano Zenaro (https://github.com/mario33881)

Function Documentation

◆ get_labels()

get_labels (   $t_conn_res)

Returns labels data.

The function executes a SELECT query to select the labels data.

Since
01_01
Parameters
array$t_conn_resarray with the DB connection object
Returns
array $action_res array with errors or data

◆ post_labels()

post_labels (   $t_conn_res)

Inserts/removes label data to the database.

The function checks if all the parameters have been passed inside the request.

Then it tries to insert the data and if the data is a duplicate, it updates the old data.

If the client sends only an id and a remove parameter, the function tries to remove the label from the table

Parameters
array$t_conn_resarray with the DB connection object
Returns
array $action_res array with errors or data
Todo:

should log the SQL error to a file... (should also log everything else)

the "error" 1110 should be a warning

Variable Documentation

◆ $response

$response = array("errors" => array())

Prepare default response array with no errors.