Database
in package
Provides functions to saves and retrieves data from a SQLite storage database for RP
Table of Contents
- __construct() : Database
- creates a new Database instance
- createRequest() : string
- creates a record for an authentication request
- dump() : array<string|int, mixed>
- executes a dump of a table
- exec() : array<string|int, mixed>
- executes a SQL query to upsert values (INSERT, UPDATE)
- getFromStore() : object
- get an object from store
- getFromStoreByURL() : object
- get an object from store by url
- getRequest() : array<string|int, mixed>
- get a saved request
- log() : array<string|int, mixed>
- saves a record on the log table
- query() : array<string|int, mixed>
- executes a SQL query to retrieve values (SELECT)
- saveToStore() : string
- save an object to the store
Methods
__construct()
creates a new Database instance
public
__construct(string $db_file) : Database
Parameters
- $db_file : string
-
path of sqlite file
Tags
Return values
Database —createRequest()
creates a record for an authentication request
public
createRequest(string $ta_id, string $op_id, string $redirect_uri[, string $state = '' ][, array<string|int, int> $acr = [] ][, array<string|int, string> $user_attributes = [] ]) : string
Parameters
- $ta_id : string
-
id of the trust anchor to wich the provider to which send the request belongs to
- $op_id : string
-
id of the provider to which send the request
- $redirect_uri : string
-
URL to which return after authentication
- $state : string = ''
-
value of the state param sent with the request
- $acr : array<string|int, int> = []
-
array of int values of the acr params to sent with the request
- $user_attributes : array<string|int, string> = []
-
array of string values of the user attributes to query with the request
Tags
Return values
string —the request id
dump()
executes a dump of a table
public
dump(string $table) : array<string|int, mixed>
Parameters
- $table : string
-
the name of the table to dump
Tags
Return values
array<string|int, mixed> —result of the dump
exec()
executes a SQL query to upsert values (INSERT, UPDATE)
public
exec(string $sql[, array<string|int, string> $values = array() ]) : array<string|int, mixed>
Parameters
- $sql : string
-
the SQL prepared query to execute
- $values : array<string|int, string> = array()
-
values to bind on the query
Tags
Return values
array<string|int, mixed> —result of the query
getFromStore()
get an object from store
public
getFromStore(string $issuer, string $type) : object
Parameters
- $issuer : string
-
client_id owner of the data
- $type : string
-
type of object
Tags
Return values
object —the object
getFromStoreByURL()
get an object from store by url
public
getFromStoreByURL(string $url) : object
Parameters
- $url : string
-
url where the object is issued
Tags
Return values
object —the object
getRequest()
get a saved request
public
getRequest(string $req_id) : array<string|int, mixed>
Parameters
- $req_id : string
-
the id of the request
Tags
Return values
array<string|int, mixed> —data of the request: req_id, timestamp, op_id, redirect_uri, state, acr, user_attributes, none, code_verifier
log()
saves a record on the log table
public
log(string $context, string $tag[, mixed $value = '' ][, string $severity = 'INFO' ]) : array<string|int, mixed>
Parameters
- $context : string
-
context for the log record
- $tag : string
-
tag for the log record
- $value : mixed = ''
-
value for the log record
- $severity : string = 'INFO'
-
[DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL]
Tags
Return values
array<string|int, mixed> —result of the save
query()
executes a SQL query to retrieve values (SELECT)
public
query(string $sql[, array<string|int, string> $values = array() ]) : array<string|int, mixed>
Parameters
- $sql : string
-
the SQL prepared query to execute (es. SELECT * FROM request WHERE code_verifier = :code_verifier)
- $values : array<string|int, string> = array()
-
values to bind on the query
Tags
Return values
array<string|int, mixed> —result of the query
saveToStore()
save an object to the store
public
saveToStore(string $issuer, string $type, string $url, string $iat, string $exp, mixed $data) : string
Parameters
- $issuer : string
-
client_id owner of the data
- $type : string
-
type of object
- $url : string
- $iat : string
-
"issued at" timestamp of object
- $exp : string
-
"expire at" timestamp of object
- $data : mixed
-
json encoded string of object
Tags
Return values
string —the record id