Class: DBJet
Source Location: /engine/lib/db/db.php
Class DBJet
Class Overview
|
Basic database interface
This class is further extended by the database jet selected. any kind of database can be used.
Basic database interface
This class is further extended by the database jet selected. Using this method, any kind of database can be used.
Located in /engine/lib/db/db.php [line 43]
Author(s):
API Tags:
|
Methods
|
Method Summary
| bool |
check_select() |
Check if the select query will return data |
| bool|resource |
delete() |
Delete a data row from the database |
| bool|array |
fetch_array() |
Fetch a row from the resultset |
| bool|array |
fetch_array_all_ex() |
Fetch all the rows from the resultset using an extended field |
| bool|array |
fetch_array_ex() |
Fetch a row from the resultset using an extended field |
| bool|array |
fetch_value() |
Fetch a single value from the resultset |
| bool|array |
get_tables() |
Get the names of all the tables in the database |
| void |
init() |
Initialize Database jet, using the configuration provided |
| bool|resource |
insert() |
Insert a new data row on the database |
| int |
num_changed() |
Get the number of changed rows in the resultset |
| int |
num_pages() |
Get the total ammount of pages that are used by the pager |
| int |
num_rows() |
Get the number of rows in the resultset |
| bool|array |
paging_fetch_array() |
Fetch a row from the resultset, using the paging mechanism |
| void |
paging_start() |
Start the automated data pager
The paging system allows you to group the results into pages, quickly and efficiently. |
| bool|resource |
query() |
Manually execute a complex SQL query |
| bool|array |
query_and_get() |
Perform an SQ query and return the first row |
| bool|resource |
replace() |
Replace a data row into the database |
| bool|resource |
select() |
Select a row from the database |
| bool |
set_row() |
Set the current resultset pointer into a different row |
| bool|resource |
update() |
Update a row on the database |
Methods
bool check_select(
string
$table, [array
$index_data = false], [array
$return_data = false], [array
$order_by = false], [array
$sort_order = false]
)
|
|
Check if the select query will return data
Check if the select query will return data
Parameters:
|
string |
$table: |
The name of the database table that the data resides on |
|
array |
$index_data: |
[Optional] The indexing fields that define the rows to fetch (ex. [name] => 'user', [password] => '1234') |
|
array |
$return_data: |
[Optional] The names of the fields that should be returned (if ommited, all of them) |
|
array |
$order_by: |
[Optional] The name of the sorting field |
|
array |
$sort_order: |
[Optional] The sort order: 'ASC' for ascending or 'DESC' for descending |
API Tags:
| Return: | Returns TRUE if data were received or FALSE if the result was empty |
| Access: | public |
bool|resource delete(
string
$table, [array
$index_data = false]
)
|
|
Delete a data row from the database
Delete a data row from the database
Parameters:
|
string |
$table: |
The name of the table that contain the data |
|
array |
$index_data: |
An array that holds the indexing information of the data being removed (Ex. [name] => 'user') |
API Tags:
| Return: | Returns false in case of error or the resultset of the executed query |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
Check if the resultset is empty
Check if the resultset is empty
API Tags:
| Return: | Returns TRUE if the resultset is empty, or FALSE otherways |
| Access: | public |
bool|array fetch_array(
[int
$mode = false], [int
$resultset = false]
)
|
|
Fetch a row from the resultset
Fetch a row from the resultset
Parameters:
|
int |
$mode: |
[Optional] The returning array key format. Can be MYSQL_ASSOC for associative array, MYSQL_NUM, for indexed array, or MYSQL_BOTH |
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
API Tags:
| Return: | Returns false in case of error or the data array if successfull |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
bool|array fetch_array_all(
[int
$mode = false], [int
$resultset = false]
)
|
|
Fetch all the rows of the resultset
Fetch all the rows of the resultset
Parameters:
|
int |
$mode: |
[Optional] The returning array key format. Can be MYSQL_ASSOC for associative array, MYSQL_NUM, for indexed array, or MYSQL_BOTH |
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
API Tags:
| Return: | Returns false in case of error or the data array if successfull |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
bool|array fetch_array_all_ex(
[int
$mode = false], [int
$resultset = false], [string
$extrafield = 'extra']
)
|
|
Fetch all the rows from the resultset using an extended field
Fetch all the rows from the resultset using an extended field
The extended field is a field in the resultset that contains PHP serialized data. Theese data will be automatically expanded and inserted in the returning array
Parameters:
|
int |
$mode: |
[Optional] The returning array key format. Can be MYSQL_ASSOC for associative array, MYSQL_NUM, for indexed array, or MYSQL_BOTH |
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
|
string |
$extrafield: |
[Optional] The name of the extra field (defaults to 'extra') |
API Tags:
| Return: | Returns false in case of error or the data array if successfull |
| Access: | public |
bool|array fetch_array_ex(
[int
$mode = false], [int
$resultset = false], [string
$extrafield = 'extra']
)
|
|
Fetch a row from the resultset using an extended field
Fetch a row from the resultset using an extended field
The extended field is a field in the resultset that contains PHP serialized data. Theese data will be automatically expanded and inserted in the returning array
Parameters:
|
int |
$mode: |
[Optional] The returning array key format. Can be MYSQL_ASSOC for associative array, MYSQL_NUM, for indexed array, or MYSQL_BOTH |
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
|
string |
$extrafield: |
[Optional] The name of the extra field (defaults to 'extra') |
API Tags:
| Return: | Returns false in case of error or the data array if successfull |
| Access: | public |
bool|array fetch_value(
[int
$resultset = false]
)
|
|
Fetch a single value from the resultset
Fetch a single value from the resultset
Parameters:
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
API Tags:
| Return: | Returns false in case of error or the data array if successfull |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
int get_error_message(
[bool
$formatted = true]
)
|
|
Get the last error message
Get the last error message
Parameters:
|
bool |
$formatted: |
If TRUE, the message will be properly, HTML formatted |
API Tags:
| Return: | Returns the HTML or text result |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
Get the names of all the tables in the database
Get the names of all the tables in the database
API Tags:
| Return: | Returns the database tables as array, or FALSE on error |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
bool|array get_table_structure(
$table
)
|
|
Get a table structure
Get a table structure
Parameters:
API Tags:
| Return: | Returns the table structure as an associative array, with key each field's name |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
void init(
array
$config
)
|
|
Initialize Database jet, using the configuration provided
Initialize Database jet, using the configuration provided
Parameters:
|
array |
$config: |
The Jet configuration (Structure depends on the Jet) |
API Tags:
Redefined in descendants as:
bool|resource insert(
string
$table, array
$data
)
|
|
Insert a new data row on the database
Insert a new data row on the database
Parameters:
|
string |
$table: |
The name of the table that will receive the new row |
|
array |
$data: |
An array that contains the field names (as keys) and the field values to add |
API Tags:
| Return: | Returns false in case of error or the resultset of the executed query |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
Get the number of changed rows in the resultset
Get the number of changed rows in the resultset
API Tags:
| Return: | Returns the number of the rows that were changed, on the last resultset |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
Get the total ammount of pages that are used by the pager
Get the total ammount of pages that are used by the pager
API Tags:
| Return: | The number of pages |
| Access: | public |
int num_rows(
[int
$resultset = false]
)
|
|
Get the number of rows in the resultset
Get the number of rows in the resultset
Parameters:
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
API Tags:
| Return: | Returns the number of the rows in the resultset |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
bool|array paging_fetch_array(
[int
$mode = false], [int
$resultset = false]
)
|
|
Fetch a row from the resultset, using the paging mechanism
Fetch a row from the resultset, using the paging mechanism
Parameters:
|
int |
$mode: |
[Optional] The returning array key format. Can be MYSQL_ASSOC for associative array, MYSQL_NUM, for indexed array, or MYSQL_BOTH |
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
API Tags:
| Return: | Returns false in case of error or when reached the end or the data array if successfull |
| Access: | public |
bool|array paging_fetch_array_ex(
[int
$mode = false], [int
$resultset = false], [
$extrafield = 'extra']
)
|
|
Fetch all the rows of the resultset, using the paging mechanism
Fetch all the rows of the resultset, using the paging mechanism
Parameters:
|
int |
$mode: |
[Optional] The returning array key format. Can be MYSQL_ASSOC for associative array, MYSQL_NUM, for indexed array, or MYSQL_BOTH |
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
|
|
$extrafield: |
|
API Tags:
| Return: | Returns false in case of error or when reached the end or the data array if successfull |
| Access: | public |
void paging_start(
int
$page, int
$rows_per_page, [int
$resultset = false]
)
|
|
Start the automated data pager
The paging system allows you to group the results into pages, quickly and efficiently.
Start the automated data pager
The paging system allows you to group the results into pages, quickly and efficiently. In order to use the paging system, you should first call the paging_start() function and then use the paging_fetch_array() function instead of fetch_array()
Parameters:
|
int |
$page: |
The active page (Starts from 0) |
|
int |
$rows_per_page: |
The maximum numbers of rows that will be allowed on each page |
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
API Tags:
bool|resource query(
string
$text
)
|
|
Manually execute a complex SQL query
Manually execute a complex SQL query
This function should be avoided when possible, because there could be jets that do not support SQL quering!
Parameters:
|
string |
$text: |
The query to execute |
API Tags:
| Return: | Returns false in case of error or the resultset of the executed query |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
bool|array query_and_get(
string
$text
)
|
|
Perform an SQ query and return the first row
Perform an SQ query and return the first row
This function should be avoided when possible, because there could be jets that do not support SQL quering!
Parameters:
|
string |
$text: |
The query to execute |
API Tags:
| Return: | Returns false in case of error or the data array if successfull |
| Access: | public |
bool|resource replace(
string
$table, array
$data
)
|
|
Replace a data row into the database
Replace a data row into the database
Parameters:
|
string |
$table: |
The name of the table that will receive the data |
|
array |
$data: |
An array that contains the field names and values. If one or more field names are indexing keys, they will define the row that will be updated. |
API Tags:
| Return: | Returns false in case of error or the resultset of the executed query |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
bool|resource select(
string
$table, [array
$index_data = false], [array
$return_data = false], [array
$order_by = false], [array
$sort_order = false]
)
|
|
Select a row from the database
Select a row from the database
Parameters:
|
string |
$table: |
The name of the database table that the data resides on |
|
array |
$index_data: |
[Optional] The indexing fields that define the rows to fetch (ex. [name] => 'user', [password] => '1234') |
|
array |
$return_data: |
[Optional] The names of the fields that should be returned (if ommited, all of them) |
|
array |
$order_by: |
[Optional] The name of the sorting field |
|
array |
$sort_order: |
[Optional] The sort order: 'ASC' for ascending or 'DESC' for descending |
API Tags:
| Return: | Returns false in case of error or the resultset of the executed query |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
bool|array select_and_get(
string
$table, [array
$index_data = false], [array
$return_data = false], [array
$order_by = false], [array
$sort_order = false]
)
|
|
Select data and fetch the first row
Select data and fetch the first row
Parameters:
|
string |
$table: |
The name of the database table that the data resides on |
|
array |
$index_data: |
[Optional] The indexing fields that define the rows to fetch (ex. [name] => 'user', [password] => '1234') |
|
array |
$return_data: |
[Optional] The names of the fields that should be returned (if ommited, all of them) |
|
array |
$order_by: |
[Optional] The name of the sorting field |
|
array |
$sort_order: |
[Optional] The sort order: 'ASC' for ascending or 'DESC' for descending |
API Tags:
| Return: | Returns false in case of error or the data array if successfull |
| Access: | public |
bool set_row(
int
$position, [int
$resultset = false]
)
|
|
Set the current resultset pointer into a different row
Set the current resultset pointer into a different row
Parameters:
|
int |
$position: |
The new position |
|
int |
$resultset: |
[Optional] The resultset to use. If not specified, the last action's resultset will be used. |
API Tags:
| Return: | Returns false in case of error or TRUE if successfull |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
bool|resource update(
string
$table, array
$index_data, array
$new_data
)
|
|
Update a row on the database
Update a row on the database
Parameters:
|
string |
$table: |
The name of the database table that the data resides on |
|
array |
$index_data: |
The indexing fields that define the row(s) to update (ex. [name] => 'user', [password] => '1234') |
|
array |
$new_data: |
The new data |
API Tags:
| Return: | Returns false in case of error or the resultset of the executed query |
| Abstract: | |
| Access: | public |
Redefined in descendants as:
|
|