|
SelfHelp WebApp
v2.0.6
A WebApp to Create WebApps for Studies in Human Sciences
|
Public Member Functions | |
| __construct ($server, $dbname, $username, $password, $names="utf8") | |
| get_dbh () | |
| execute_db ($sql) | |
| execute_update_db ($sql, $arguments=array()) | |
| query_db ($sql, $arguments=array(), $fetch_style=PDO::FETCH_ASSOC) | |
| query_db_first ($sql, $arguments=array(), $fetch_style=PDO::FETCH_ASSOC) | |
| remove_by_fk ($table, $fk, $id) | |
| remove_by_ids ($table, $ids) | |
| set_db_locale ($locale) | |
| select_table ($table) | |
| select_by_fk ($table, $fk, $id) | |
| select_by_fks ($table, $fks) | |
| select_by_uid ($table, $id) | |
| select_by_uid_join ($table, $id) | |
| insert ($table, $entries, $update_entries=array()) | |
| insert_mult ($table, $cols, $data) | |
| update_by_ids ($table, $entries, $ids) | |
Private Attributes | |
| $dbh = null | |
Class to handle the global communication with the DB
| BaseDb::__construct | ( | $server, | |
| $dbname, | |||
| $username, | |||
| $password, | |||
$names = "utf8" |
|||
| ) |
Open connection to mysql database
| string | $server, | address of server |
| string | $dbname, | name of database |
| string | $username, | username |
| string | $password, | password |
| string | $names, | charset (optional, default: utf8) |
| BaseDb::execute_db | ( | $sql | ) |
Exectute an arbitrary query on the db.
| string | $sql | The query to be executed. |
| int | The number of affected rows. |
| BaseDb::execute_update_db | ( | $sql, | |
$arguments = array() |
|||
| ) |
Exectute an arbitrary update query on the db.
| string | $sql | The query to be executed. |
| array | $arguments | An associative array with value key pairs where the keys are variable identifiers used in the query (e.g ':id') which will be replaced with the associated value on query execution. |
| array | The number of affected rows or false if the query failed. |
| BaseDb::get_dbh | ( | ) |
Return the PDO handler.
| object | The database handler. |
| BaseDb::insert | ( | $table, | |
| $entries, | |||
$update_entries = array() |
|||
| ) |
Insert values into db table.
| string | $table | The name of the db table. |
| array | $entries | An associative array of db entries e.g. colname => foo |
| array | $update_entries | An associative array of db entries e.g. colname => foo. This array indicates which fields to update should the entry already exist. |
| int | The inserted id if succeded, false otherwise. |
| BaseDb::insert_mult | ( | $table, | |
| $cols, | |||
| $data | |||
| ) |
Insert multiple rows o values into db table.
| string | $table | The name of the db table. |
| array | $cols | An array of db collumn names. |
| array | $data | A matrix of values. |
| int | The last inserted id if succeded, false otherwise. |
| BaseDb::query_db | ( | $sql, | |
$arguments = array(), |
|||
$fetch_style = PDO::FETCH_ASSOC |
|||
| ) |
Exectute an arbitrary select query on the db.
| string | $sql | The query to be executed. |
| array | $arguments | An associative array with value key pairs where the keys are variable identifiers used in the query (e.g ':id') which will be replaced with the associated value on query execution. |
| enum | $fetch_style | Controls how the next row will be returned to the caller. Refer to the official documentation for more information. |
| array | An array with all row entries or false if no entry was selected. |
Referenced by PageDb\fetch_accessible_pages(), PageDb\fetch_nav_children(), PageDb\fetch_page_fields(), PageDb\fetch_page_sections(), PageDb\fetch_section_children(), and PageDb\fetch_section_fields().
| BaseDb::query_db_first | ( | $sql, | |
$arguments = array(), |
|||
$fetch_style = PDO::FETCH_ASSOC |
|||
| ) |
Exectute an arbitrary select query on the db and return the first matching row.
| string | $sql | The query to be executed. |
| array | $arguments | An associative array with value key pairs where the keys are variable identifiers used in the query (e.g ':id') which will be replaced with the associated value on query execution. |
| enum | $fetch_style | Controls how the next row will be returned to the caller. Refer to the official documentation for more information. |
| array | All row entries or false if no entry was selected. |
Referenced by PageDb\fetch_field_id(), PageDb\fetch_page_id_by_keyword(), PageDb\fetch_page_info(), PageDb\fetch_page_keyword_by_id(), PageDb\fetch_section_info_by_id(), and PageDb\fetch_user_name().
| BaseDb::remove_by_fk | ( | $table, | |
| $fk, | |||
| $id | |||
| ) |
Remove all rows where the foreign key matches.
| string | $table | The name of the db table. |
| string | $fk | The name of the foreign key. |
| int | $id | The foreign key of the row to be selected |
| bool | True on success, false otherwise. |
| BaseDb::remove_by_ids | ( | $table, | |
| $ids | |||
| ) |
Remove all rows where the foreign key matches.
| string | $table | The name of the db table. |
| array | $ids | An associative array of where conditions e.g WHERE $key = $value. The conditions are concatenated with AND. |
| bool | True on success, false otherwise. |
| BaseDb::select_by_fk | ( | $table, | |
| $fk, | |||
| $id | |||
| ) |
Get a single row of a db table by foreign key.
| string | $table | The name of the db table. |
| string | $fk | The name of the foreign key. |
| int | $id | The foreign key of the row to be selected |
| array | An array with all row entries or false if no entry was selected |
| BaseDb::select_by_fks | ( | $table, | |
| $fks | |||
| ) |
Get a single row of a db table by foreign key constarints.
| string | $table | The name of the db table. |
| array | $fks | An associative array of where conditions e.g WHERE $key = $value. The conditions are concatenated with AND. |
| array | An array with all row entries or false if no entry was selected |
| BaseDb::select_by_uid | ( | $table, | |
| $id | |||
| ) |
Get a single row of a db table by unique id.
| string | $table | The name of the db table. |
| int | $id | The unique id of the row to be selected. |
| array | An array with all row entries or false if no entry was selected. |
Referenced by select_by_uid_join().
| BaseDb::select_by_uid_join | ( | $table, | |
| $id | |||
| ) |
Get a single row of a data table by unique id and get all names of foreign keys by joining the linked tables. The naming convention to make this work is as follows:
| string | $table | The name of the db table. |
| int | $id | The unique id of the row to be selected. |
| array | An array with all entries of the row or false if no entry was selected. |
| BaseDb::select_table | ( | $table | ) |
Get all rows from a table.
| string | $table | The name of the db table. |
| array | An array with all row entries or false if no entry was selected. |
| BaseDb::set_db_locale | ( | $locale | ) |
Set locale time name variable.
| string | $locale | The locale indentifier, e.g. de_CH. |
| BaseDb::update_by_ids | ( | $table, | |
| $entries, | |||
| $ids | |||
| ) |
Update values in db defined by one or several ids.
| string | $table | The name of the db table. |
| array | $entries | An associative array of db entries e.g. $["colname1"] = "foo". |
| array | $ids | An associative array of where conditions e.g WHERE $key = $value. The conditions are concatenated with AND. |
| bool | true if succeded, false otherwise. |
|
private |
The DB handler.
Referenced by get_dbh().