Database Driver.

package core_database_drivers
inherited_from \Database_super_mysql

 Methods

Find whether the database may run GROUP BY unfettered with restrictions on the SELECT'd fields having to be represented in it or aggregate functions

can_arbitrary_groupby() : boolean
Inherited

Returns

booleanWhether it can

Change the primary key of a table.

db_change_primary_key(\ID_TEXT $table_name, array $new_key, array $db) 
Inherited

Parameters

$table_name

\ID_TEXT

The name of the table to create the index on

$new_key

array

A list of fields to put in the new key

$db

array

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.

db_close_connections() 
Inherited

Create a table index.

db_create_index(\ID_TEXT $table_name, \ID_TEXT $index_name, string $_fields, array $db) 
Inherited

Parameters

$table_name

\ID_TEXT

The name of the table to create the index on

$index_name

\ID_TEXT

The index name (not really important at all)

$_fields

string

Part of the SQL query: a comma-separated list of fields to use on the index

$db

array

The DB connection to make on

Create a new table.

db_create_table(\ID_TEXT $table_name, array $fields, array $db, \ID_TEXT $raw_table_name, boolean $save_bytes = false
Inherited

Parameters

$table_name

\ID_TEXT

The table name

$fields

array

A map of field names to Composr field types (with *#? encodings)

$db

array

The DB connection to make on

$raw_table_name

\ID_TEXT

The table name with no table prefix

$save_bytes

boolean

Whether to use lower-byte table storage, with tradeoffs of not being able to support all unicode characters; use this if key length is an issue

Get the default password for making db connections (used by the installer as a default).

db_default_password() : string
Inherited

Returns

stringThe default password for db connections

Get the default user for making db connections (used by the installer as a default).

db_default_user() : string
Inherited

Returns

stringThe default user for db connections

Delete a table.

db_drop_table_if_exists(\ID_TEXT $table, array $db) 
Inherited

Parameters

$table

\ID_TEXT

The table name

$db

array

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.

db_empty_is_null() : boolean
Inherited

Returns

booleanWhether a blank string IS NULL

Encode a LIKE string comparision fragement for the database system. The pattern is a mixture of characters and ? and % wilcard symbols.

db_encode_like(string $pattern) : string
Inherited

Parameters

$pattern

string

The pattern

Returns

stringThe encoded 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.

db_escape_string(string $string) : string

Parameters

$string

string

The string

Returns

stringThe escaped string

Assemble part of a WHERE clause for doing full-text search

db_full_text_assemble(string $content, boolean $boolean) : string
Inherited

Parameters

$content

string

Our match string (assumes "?" has been stripped already)

$boolean

boolean

Whether to do a boolean full text search

Returns

stringPart of a WHERE clause for doing full-text search

Get a database connection. This function shouldn't be used by you, as a connection to the database is established automatically.

db_get_connection(boolean $persistent, string $db_name, string $db_host, string $db_user, string $db_password, boolean $fail_ok = false) : \?array

Parameters

$persistent

boolean

Whether to create a persistent connection

$db_name

string

The database name

$db_host

string

The database host (the server)

$db_user

string

The database connection username

$db_password

string

The database connection password

$fail_ok

boolean

Whether to on error echo an error and return with a NULL, rather than giving a critical error

Returns

\?arrayA database connection (note for MySQL, it's actually a pair, containing the database name too: because we need to select the name before each query on the connection) (null: error)

Get the ID of the first row in an auto-increment table (used whenever we need to reference the first).

db_get_first_id() : integer
Inherited

Returns

integerFirst ID used

Get the rows returned from a SELECT query.

db_get_query_rows(resource $results) : array

Parameters

$results

resource

The query result pointer

Returns

arrayA list of row maps

Get a map of Composr field types, to actual database types.

db_get_type_remap() : array
Inherited

Returns

arrayThe map

Find whether collate support is present

db_has_collate_settings(array $db) : boolean

Parameters

$db

array

A DB connection

Returns

booleanWhether it is

Find whether expression ordering support is present

db_has_expression_ordering(array $db) : boolean
Inherited

Parameters

$db

array

A DB connection

Returns

booleanWhether it is

Find whether full-text-search is present

db_has_full_text(array $db) : boolean

Parameters

$db

array

A DB connection

Returns

booleanWhether it is

Find whether full-text-boolean-search is present

db_has_full_text_boolean() : boolean

Returns

booleanWhether it is

Find whether subquery support is present

db_has_subqueries(array $db) : boolean

Parameters

$db

array

A DB connection

Returns

booleanWhether it is

Determine whether the database is a flat file database, and thus not have a meaningful connect username and password.

db_is_flat_file_simple() : boolean
Inherited

Returns

booleanWhether the database is a flat file database

This function is a very basic query executor. It shouldn't usually be used by you, as there are abstracted versions available.

db_query(string $query, array $db_parts, \?integer $max = null, \?integer $start = null, boolean $fail_ok = false, boolean $get_insert_id = false) : \?mixed

Parameters

$query

string

The complete SQL query

$db_parts

array

A DB connection

$max

\?integer

The maximum number of rows to affect (null: no limit)

$start

\?integer

The start row to affect (null: no specification)

$fail_ok

boolean

Whether to output an error on failure

$get_insert_id

boolean

Whether to get the autoincrement ID created for an insert query

Returns

\?mixedThe results (null: no results), or the insert ID

Encode an SQL statement fragment for a conditional to see if two strings are equal.

db_string_equal_to(\ID_TEXT $attribute, string $compare) : string
Inherited

Parameters

$attribute

\ID_TEXT

The attribute

$compare

string

The comparison

Returns

stringThe SQL

Encode an SQL statement fragment for a conditional to see if two strings are not equal.

db_string_not_equal_to(\ID_TEXT $attribute, string $compare) : string
Inherited

Parameters

$attribute

\ID_TEXT

The attribute

$compare

string

The comparison

Returns

stringThe SQL

Whether to use InnoDB for MySQL. Change this function by hand - official only MyISAM supported

using_innodb() : boolean
Inherited

Returns

booleanAnswer

 Properties

 

$cache_db

$cache_db 

Default

array()
 

$last_select_db

$last_select_db 

Default

null
 

$reconnected_once

$reconnected_once 

Default

false