Change the primary key of a table.
void
db_change_primary_key
(ID_TEXT $table_name, array $new_key, array $db)
-
ID_TEXT
$table_name: The name of the table to create the index on
-
array
$new_key: A list of fields to put in the new key
-
array
$db: The DB connection to make on
Close the database connections. We don't really need to close them (will close at exit), just disassociate so we can refresh them.
void
db_close_connections
()
Create a table index.
void
db_create_index
(ID_TEXT $table_name, ID_TEXT $index_name, string $_fields, array $db)
-
ID_TEXT
$table_name: The name of the table to create the index on
-
ID_TEXT
$index_name: The index name (not really important at all)
-
string
$_fields: Part of the SQL query: a comma-separated list of fields to use on the index
-
array
$db: The DB connection to make on
Create a new table.
void
db_create_table
(ID_TEXT $table_name, array $fields, array $db)
-
ID_TEXT
$table_name: The table name
-
array
$fields: A map of field names to ocPortal field types (with *#? encodings)
-
array
$db: The DB connection to make on
Get the default password for making db connections (used by the installer as a default).
string
db_default_password
()
Get the default user for making db connections (used by the installer as a default).
string
db_default_user
()
Delete a table.
void
db_drop_if_exists
(ID_TEXT $table, array $db)
-
ID_TEXT
$table: The table name
-
array
$db: The DB connection to delete on
This function is internal to the database system, allowing SQL statements to be build up appropriately. Some databases require IS NULL to be used to check for blank strings.
boolean
db_empty_is_null
()
Encode a LIKE string comparision fragement for the database system. The pattern is a mixture of characters and ? and % wilcard symbols.
string
db_encode_like
(string $pattern)
-
string
$pattern: The pattern
Escape a string so it may be inserted into a query. If SQL statements are being built up and passed using db_query then it is essential that this is used for security reasons. Otherwise, the abstraction layer deals with the situation.
string
db_escape_string
(string $string)
-
string
$string: The string
Get a database connection. This function shouldn't be used by you, as a connection to the database is established automatically.
?array
db_get_connection
(boolean $persistent, string $db_name, string $db_host, string $db_user, string $db_password, [boolean $fail_ok = false])
-
boolean
$persistent: Whether to create a persistant connection
-
string
$db_name: The database name
-
string
$db_host: The database host (the server)
-
string
$db_user: The database connection username
-
string
$db_password: The database connection password
-
boolean
$fail_ok: Whether to on error echo an error and return with a NULL, rather than giving a critical error
Get the ID of the first row in an auto-increment table (used whenever we need to reference the first).
integer
db_get_first_id
()
Get the rows returned from a SELECT query.
array
db_get_query_rows
(resource $results, [?integer $start = NULL])
-
resource
$results: The query result pointer
-
?integer
$start: Whether to start reading from (NULL: irrelevant for this forum driver)
Get a map of ocPortal field types, to actual mySQL types.
array
db_get_type_remap
()
Find whether full-text-search is present
boolean
db_has_full_text
(array $db)
-
array
$db: A DB connection
Determine whether the database is a flat file database, and thus not have a meaningful connect username and password.
boolean
db_is_flat_file_simple
()
This function is a very basic query executor. It shouldn't usually be used by you, as there are abstracted versions available.
?mixed
db_query
(string $query, array $db, [?integer $max = NULL], [?integer $start = NULL], [boolean $fail_ok = false], [boolean $get_insert_id = false])
-
string
$query: The complete SQL query
-
array
$db: A DB connection
-
?integer
$max: The maximum number of rows to affect (NULL: no limit)
-
?integer
$start: The start row to affect (NULL: no specification)
-
boolean
$fail_ok: Whether to output an error on failure
-
boolean
$get_insert_id: Whether to get the autoincrement ID created for an insert query
Encode an SQL statement fragment for a conditional to see if two strings are equal.
string
db_string_equal_to
(ID_TEXT $attribute, string $compare)
-
ID_TEXT
$attribute: The attribute
-
string
$compare: The comparison
Encode an SQL statement fragment for a conditional to see if two strings are not equal.
string
db_string_not_equal_to
(ID_TEXT $attribute, string $compare)
-
ID_TEXT
$attribute: The attribute
-
string
$compare: The comparison