CoreAPI
[ class tree: CoreAPI ] [ index: CoreAPI ] [ all elements ]

Procedural File: database_api.php

Source Location: /core/database_api.php



Page Details:

Database

This is the general interface for all database calls. Modifications required for database support, outside of adodb support should occur here.




Tags:

copyright:  Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
copyright:  Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
link:  http://www.mantisbt.org
usedby:  bug_set_field()
usedby:  bug_assign()
usedby:  bug_get_attachments()
usedby:  bug_reopen()
usedby:  bug_monitor()
usedby:  bug_unmonitor()
usedby:  bug_monitor_copy()
usedby:  bug_get_bugnote_stats()
usedby:  bug_update_date()
usedby:  bug_delete_all()
usedby:  access_api.php
usedby:  BugData::create()
uses:  config_api.php
usedby:  bug_cache_row()
usedby:  bug_cache_array_rows()
usedby:  bug_is_overdue()
usedby:  bug_text_cache_row()
usedby:  bug_get_newest_bugnote_timestamp()


Includes:

require_once('adodb'.DIRECTORY_SEPARATOR.'adodb.inc.php') [line 35]
requires adodb library




bool $ADODB_FETCH_MODE [line 59]

set adodb fetch mode

Default value:   ADODB_FETCH_ASSOC


[ Top ]



bool $g_db_connected [line 47]

Stores whether a database connection was succesfully opened.

Default value:   false


[ Top ]



bool $g_db_log_queries [line 53]

Store whether to log queries ( used for show_queries_count/query list)

Default value:   config_get_global( 'show_queries_list' )


[ Top ]



int $g_db_param_count [line 65]

Tracks the query parameter count for use with db_aparam().

Default value:   0


[ Top ]



array $g_queries_array [line 41]

An array in which all executed queries are stored. This is used for profiling

Default value:   array()


[ Top ]





PLUGINS_DISABLED [line 923]

PLUGINS_DISABLED = true

[ Top ]




db_affected_rows [line 427]

int db_affected_rows( [ADORecordSet $p_result = Database Query Record Set to retrieve affected rows for.])

Retrieve number of rows affected by a specific database query



Tags:

return:  Affected Rows


Parameters

ADORecordSet   $p_result   Database Query Record Set to retrieve affected rows for.
[ Top ]



db_check_database_support [line 140]

bool db_check_database_support( $p_db_type)

Returns whether php supprot for a database is enabled



Tags:

return:  indicating if php current supports the given database type


Parameters

   $p_db_type  
[ Top ]



db_close [line 662]

void db_close( )

close the connection.

Not really necessary most of the time since a connection is automatically closed when a page finishes loading.




[ Top ]



db_connect [line 78]

bool db_connect( string $p_dsn, [string $p_hostname = null], [string $p_username = null], [string $p_password = null], [string $p_database_name = null], [string $p_db_schema = null], [bool $p_pconnect = false])

Open a connection to the database.



Tags:

return:  indicating if the connection was successful


Parameters

string   $p_dsn   Database connection string ( specified instead of other params)
string   $p_hostname   Database server hostname
string   $p_username   database server username
string   $p_password   database server password
string   $p_database_name   database name
string   $p_db_schema   Schema name (only used if database type is DB2)
bool   $p_pconnect   Use a Persistent connection to database
[ Top ]



db_count_queries [line 847]

int db_count_queries( )

count queries



[ Top ]



db_count_unique_queries [line 857]

int db_count_unique_queries( )

count unique queries



[ Top ]



db_error [line 650]

void db_error( [ $p_query = null])

send both the error number and error message and query (optional) as paramaters for a triggered error



Tags:

todo:  Use/Behaviour of this function should be reviewed before 1.2.0 final


Parameters

   $p_query  
[ Top ]



db_error_msg [line 640]

string db_error_msg( )

Returns the last status or error message. Returns the last status or error message. The error message is reset when Execute() is called.

This can return a string even if no error occurs. In general you do not need to call this function unless an ADOdb function returns false on an error.




Tags:

return:  last error string
todo:  Use/Behaviour of this function should be reviewed before 1.2.0 final


[ Top ]



db_error_num [line 628]

int db_error_num( )

Returns the last error number. The error number is reset after every call to Execute(). If 0 is returned, no error occurred.



Tags:

return:  last error number
todo:  Use/Behaviour of this function should be reviewed before 1.2.0 final


[ Top ]



db_fetch_array [line 438]

array db_fetch_array( &$p_result, bool|ADORecordSet $p_result)

Retrieve the next row returned from a specific database query



Tags:

return:  Database result


Parameters

bool|ADORecordSet   $p_result   Database Query Record Set to retrieve next result for.
   &$p_result  
[ Top ]



db_field_exists [line 606]

bool db_field_exists( string $p_field_name, string $p_table_name)

Check if the specified field exists in a given table



Tags:

return:  indicating whether the field exists


Parameters

string   $p_field_name   a database field name
string   $p_table_name   a valid database table name
[ Top ]



db_field_names [line 617]

array db_field_names( string $p_table_name)

Retrieve list of fields for a given table



Tags:

return:  array of fields on table


Parameters

string   $p_table_name   a valid database table name
[ Top ]



db_get_table [line 889]

string db_get_table( $p_option)

get database table name



Tags:

return:  containing full database table name


Parameters

   $p_option  
[ Top ]



db_get_table_list [line 906]

array db_get_table_list( )

get list database tables



Tags:

return:  containing table names


[ Top ]



db_helper_compare_days [line 828]

string db_helper_compare_days( $p_date1_id_or_column $p_date1_id_or_column, $p_date2_id_or_column $p_date2_id_or_column, $p_limitstring $p_limitstring)

A helper function to compare two dates against a certain number of days



Tags:

return:  returns database query component to compare dates
todo:  Check if there is a way to do that using ADODB rather than implementing it here.


Parameters

$p_date1_id_or_column   $p_date1_id_or_column  
$p_date2_id_or_column   $p_date2_id_or_column  
$p_limitstring   $p_limitstring  
[ Top ]



db_helper_like [line 808]

string db_helper_like( string $p_field_name, [bool $p_case_sensitive = false])

A helper function that generates a case-sensitive or case-insensitive like phrase based on the current db type.

The field name and value are assumed to be safe to insert in a query (i.e. already cleaned).




Tags:

return:  returns (field LIKE 'value') OR (field ILIKE 'value')


Parameters

string   $p_field_name   The name of the field to filter on.
bool   $p_case_sensitive   true: case sensitive, false: case insensitive
[ Top ]



db_index_exists [line 579]

bool db_index_exists( string $p_table_name, string $p_index_name)

Check if the specified table index exists.



Tags:

return:  indicating whether the index exists


Parameters

string   $p_table_name   a valid database table name
string   $p_index_name   a valid database index name
[ Top ]



db_insert_id [line 532]

int db_insert_id( [string $p_table = null], [ $p_field = "id"])

return the last inserted id for a specific database table



Tags:

return:  last successful insert id


Parameters

string   $p_table   a valid database table name
   $p_field  
[ Top ]



db_is_connected [line 130]

bool db_is_connected( )

Returns whether a connection to the database exists



Tags:

return:  indicating if the a database connection has been made
global:  stores $g_db_connected: database connection state


[ Top ]



db_is_db2 [line 224]

bool db_is_db2( )

Checks if the database driver is DB2



Tags:

return:  true if db2


[ Top ]



db_is_mssql [line 208]

bool db_is_mssql( )

Checks if the database driver is MS SQL



Tags:

return:  true if postgres


[ Top ]



db_is_mysql [line 174]

bool db_is_mysql( )

Checks if the database driver is MySQL



Tags:

return:  true if mysql


[ Top ]



db_is_pgsql [line 190]

bool db_is_pgsql( )

Checks if the database driver is PostgreSQL



Tags:

return:  true if postgres


[ Top ]



db_minutes_to_hhmm [line 797]

string db_minutes_to_hhmm( [int $p_min = 0])

convert minutes to a time format [h]h:mm



Tags:

return:  representing formatted duration string in hh:mm format.


Parameters

int   $p_min   integer representing number of minutes
[ Top ]



db_now [line 786]

string db_now( )

return current timestamp for DB



Tags:

return:  Formatted Date for DB insertion e.g. 1970-01-01 00:00:00 ready for database insertion
todo:  add param bool $p_gmt whether to use GMT or current timezone (default false)


[ Top ]



db_num_rows [line 416]

int db_num_rows( ADORecordSet $p_result)

Retrieve number of rows returned for a specific database query



Tags:

return:  Record Count


Parameters

ADORecordSet   $p_result   Database Query Record Set to retrieve record count for.
[ Top ]



db_param [line 404]

string db_param( )

Generate a string to insert a parameter into a database query string



Tags:

return:  'wildcard' matching a paramater in correct ordered format for the current database.


[ Top ]



db_prepare_binary_string [line 725]

string db_prepare_binary_string( string $p_string)

prepare a binary string before DB insertion



Tags:

return:  prepared database query string
todo:  Use/Behaviour of this function should be reviewed before 1.2.0 final


Parameters

string   $p_string   unprepared binary data
[ Top ]



db_prepare_bool [line 777]

int db_prepare_bool( $p_bool, boolean $p_boolean)

prepare a boolean for database insertion.



Tags:

return:  integer representing boolean
deprecated:  db_query_bound should be used in preference to this function. This function may be removed in 1.2.0 final
todo:  Use/Behaviour of this function should be reviewed before 1.2.0 final


Parameters

boolean   $p_boolean   boolean
   $p_bool  
[ Top ]



db_prepare_double [line 766]

double db_prepare_double( double $p_double)

prepare a double for database insertion.



Tags:

return:  double
deprecated:  db_query_bound should be used in preference to this function. This function may be removed in 1.2.0 final
todo:  Use/Behaviour of this function should be reviewed before 1.2.0 final


Parameters

double   $p_double   double
[ Top ]



db_prepare_int [line 755]

int db_prepare_int( int $p_int)

prepare a int for database insertion.



Tags:

return:  integer
deprecated:  db_query_bound should be used in preference to this function. This function may be removed in 1.2.0 final
todo:  Use/Behaviour of this function should be reviewed before 1.2.0 final


Parameters

int   $p_int   integer
[ Top ]



db_prepare_string [line 674]

string db_prepare_string( string $p_string)

prepare a string before DB insertion



Tags:

return:  prepared database query string
deprecated:  db_query_bound should be used in preference to this function. This function may be removed in 1.2.0 final


Parameters

string   $p_string   unprepared string
[ Top ]



db_query [line 247]

ADORecordSet|bool db_query( string $p_query, [int $p_limit = -1], [int $p_offset = -1])

execute query, requires connection to be opened An error will be triggered if there is a problem executing the query.



Tags:

return:  adodb result set or false if the query failed.
global:  array $g_queries_array: of previous executed queries for profiling
global:  adodb $g_db: database connection object
global:  boolean $g_db_log_queries: indicating whether queries array is populated
deprecated:  db_query_bound should be used in preference to this function. This function will likely be removed in 1.2.0 final


Parameters

string   $p_query   Query string to execute
int   $p_limit   Number of results to return
int   $p_offset   offset query results for paging
[ Top ]



db_query_bound [line 302]

ADORecordSet|bool db_query_bound( string $p_query, [array $arr_parms = null], [int $p_limit = -1], [int $p_offset = -1])

execute query, requires connection to be opened An error will be triggered if there is a problem executing the query.



Tags:

return:  adodb result set or false if the query failed.
global:  array $g_queries_array: of previous executed queries for profiling
global:  adodb $g_db: database connection object
global:  boolean $g_db_log_queries: indicating whether queries array is populated


Parameters

string   $p_query   Parameterlised Query string to execute
array   $arr_parms   Array of parameters matching $p_query
int   $p_limit   Number of results to return
int   $p_offset   offset query results for paging
[ Top ]



db_result [line 507]

mixed db_result( bool|ADORecordSet $p_result, [int $p_index1 = 0], [int $p_index2 = 0])

Retrieve a result returned from a specific database query



Tags:

return:  Database result


Parameters

bool|ADORecordSet   $p_result   Database Query Record Set to retrieve next result for.
int   $p_index1   Row to retrieve (optional)
int   $p_index2   Column to retrieve (optional)
[ Top ]



db_table_exists [line 548]

bool db_table_exists( string $p_table_name)

Check if the specified table exists.



Tags:

return:  indicating whether the table exists


Parameters

string   $p_table_name   a valid database table name
[ Top ]



db_time_queries [line 875]

int db_time_queries( )

get total time for queries



[ Top ]



Documentation generated on Sun, 12 Dec 2010 23:50:23 +0900 by phpDocumentor 1.4.3
inserted by FC2 system