Procedural File: lib-database.php
Source Location: /system/lib-database.php
Page Details:
This is the high-level database layer for Geeklog (for the low-level stuff, see the system/databases directory).
NOTE: As of Geeklog 1.3.5 you should not have to edit this file any more.
Includes:
require_once($_CONF['path_system'].'databases/'.$_DB_dbms.'.class.php') [line 132]
Include appropriate DBMS object
DB_affectedRows [line 426]
int DB_affectedRows(
object $recordset)
|
|
Retrieves returns the number of effected rows for last query Retrieves returns the number of effected rows for last query
Tags:
Parameters
| object |
$recordset |
The recordset to operate on |
DB_change [line 294]
void DB_change(
string $table, string $item_to_set, string $value_to_set, [array|string $id = ''], [array|string $value = ''], [string $return_page = ''], [boolean $supress_quotes = false])
|
|
Changes records in a table This will change the data in the given table that meet the given criteria and will redirect user to another page if told to do so
Parameters
| string |
$table |
Table to perform change on |
| string |
$item_to_set |
field name to set |
| string |
$value_to_set |
Value to set abovle field to |
| array|string |
$id |
field name(s) to use in where clause |
| array|string |
$value |
Value(s) to use in where clause |
| string |
$return_page |
page to send user to when done with change |
| boolean |
$supress_quotes |
whether or not to use single quotes in where clause |
DB_checkTableExists [line 551]
boolean DB_checkTableExists(
string $table)
|
|
Check if a table exists
Tags:
Parameters
DB_copy [line 339]
void DB_copy(
string $table, string $fields, string $values, string $tablefrom, array|string $id, array|string $value, [string $return_page = ''])
|
|
Copies a record from one table to another (can be the same table) This will use a REPLACE INTO...SELECT FROM to copy a record from one table to another table. They can be the same table.
Parameters
| string |
$table |
Table to insert record into |
| string |
$fields |
Comma delmited list of fields to copy over |
| string |
$values |
Values to store in database field |
| string |
$tablefrom |
Table to get record from |
| array|string |
$id |
Field name(s) to use in where clause |
| array|string |
$value |
Value(s) to use in where clause |
| string |
$return_page |
Page to send user to when done |
DB_count [line 317]
int DB_count(
string $table, [array|string $id = ''], [array|string $value = ''])
|
|
Count records in a table This will return the number of records which meet the given criteria in the given table.
Tags:
Parameters
| string |
$table |
Table to perform count on |
| array|string |
$id |
field name(s) to use in where clause |
| array|string |
$value |
Value(s) to use in where clause |
DB_createDatabaseStructures [line 489]
boolean DB_createDatabaseStructures(
)
|
|
Creates database structures for fresh installation This may not be used by Geeklog currently
Tags:
DB_delete [line 247]
void DB_delete(
string $table, array|string $id, array|string $value, [string $return_page = ''])
|
|
Deletes data from the database This will delete some data from the given table where id = value
Parameters
| string |
$table |
Table to delete data from |
| array|string |
$id |
field name(s) to use in where clause |
| array|string |
$value |
value(s) to use in where clause |
| string |
$return_page |
page to send user to when done |
DB_displayError [line 174]
void DB_displayError(
boolean $flag)
|
|
Setting this on will return the SQL error message. Default is to not display or return the SQL error but to record it in the error.log file
Parameters
| boolean |
$flag |
true or false |
DB_doDatabaseUpgrade [line 503]
boolean DB_doDatabaseUpgrade(
string $current_gl_version)
|
|
Executes the sql upgrade script(s)
Tags:
Parameters
| string |
$current_gl_version |
version of geeklog to upgrade from |
DB_error [line 474]
returns a database error string Returns an database error message
Tags:
DB_fetchArray [line 443]
Array DB_fetchArray(
object $recordset, [boolean $both = true])
|
|
Retrieves record from a recordset Gets the next record in a recordset and returns in array
Tags:
Parameters
| object |
$recordset |
The recordset to operate on |
| boolean |
$both |
get both assoc and numeric indices |
DB_fieldName [line 410]
string DB_fieldName(
object $recordset, int $fnumber)
|
|
Retrieves returns the field name for a field Returns the field name for a given field number
Tags:
Parameters
| object |
$recordset |
The recordset to operate on |
| int |
$fnumber |
field number to return the name of |
DB_getItem [line 268]
mixed DB_getItem(
string $table, string $what, [string $selection = ''])
|
|
Gets a single item from the database
Tags:
Parameters
| string |
$table |
Table to get item from |
| string |
$what |
field name to get |
| string |
$selection |
Where clause to use in SQL |
DB_insertId [line 459]
int DB_insertId(
[resources $link_identifier = ''], [ $sequence = ''])
|
|
Returns the last ID inserted Returns the last auto_increment ID generated
Tags:
Parameters
| resources |
$link_identifier |
identifier for opened link |
| |
$sequence |
|
DB_lockTable [line 520]
void DB_lockTable(
string $table)
|
|
Lock a table Locks a table for write operations
Tags:
Parameters
| string |
$table |
Table to lock |
DB_numFields [line 393]
int DB_numFields(
object $recordset)
|
|
Retrieves the number of fields in a recordset This returns the number of fields in a recordset
Tags:
Parameters
| object |
$recordset |
The recordset to operate on |
DB_numRows [line 359]
int DB_numRows(
object $recordset)
|
|
Retrieves the number of rows in a recordset This returns the number of rows in a recordset
Tags:
Parameters
| object |
$recordset |
The recordset to operate one |
DB_query [line 191]
object Returns DB_query(
mixed $sql, [int $ignore_errors = 0])
|
|
Executes a query on the db server This executes the passed SQL and returns the recordset or errors out
Tags:
Parameters
| mixed |
$sql |
String or array of strings of SQL to be executed |
| int |
$ignore_errors |
If 1 this function supresses any error messages |
DB_result [line 377]
(depends DB_result(
object $recordset, int $row, string $field)
|
|
Retrieves the contents of a field This returns the contents of a field from a result set
Tags:
Parameters
| object |
$recordset |
The recordset to operate on |
| int |
$row |
row to get data from |
| string |
$field |
field to return |
DB_save [line 224]
void DB_save(
string $table, string $fields, string $values, [string $return_page = ''])
|
|
Saves information to the database This will use a REPLACE INTO to save a record into the database. NOTE: this function is going to change in the near future to remove dependency of REPLACE INTO. Please use DB_query if you can
Parameters
| string |
$table |
The table to save to |
| string |
$fields |
Comma demlimited list of fields to save |
| string |
$values |
Values to save to the database table |
| string |
$return_page |
URL to send user to when done |
DB_setDebug [line 161]
void DB_setDebug(
boolean $flag)
|
|
Turns debug mode on for the database library Setting this to true will cause the database code to print out various debug messages. Setting it to false will supress the messages (is false by default). NOTE: Gl developers have put many useful debug messages into the mysql implementation of this. If you are using something other than MySQL and if the GL team did not write it then you may or may not get something useful by turning this on.
Parameters
| boolean |
$flag |
true or false |
DB_unlockTable [line 537]
void DB_unlockTable(
string $table)
|
|
Unlock a table Unlocks a table after DB_lockTable
Tags:
Parameters
| string |
$table |
Table to unlock |
|