Class database

Description

Define a database. This is a parent class to all of the supported

database flavours. It holds the main data describing a database and it's connection. The actual functionality to connect to a physical database and access its data is defined in the child classes of this one. For example, see file 'db-postgres.php'.

Normal users of the system should not have to deal with this class directly.

The datasources class is a container for multiple 'databases' or instances of this class.

Located in /database-defs.php (line 584)


	
			
Variable Summary
 mixed $connected
 mixed $datestyle
 mixed $dbid
 mixed $enc
 mixed $host
 mixed $name
 mixed $passwd
 mixed $persistent
 mixed $port
 mixed $rid
 mixed $timer
 mixed $type
 mixed $user
Method Summary
 database database ([string $name = ""], [string $user = ""], [string $passwd = ""], [string $host = ""], integer $port, [string $enc = ""], [string $datestyle = ""])
 void affectedrows (mixed $rid)
 boolean begin_transaction ()
 boolean bool_from_db_value (mixed $dbvalue)
 boolean commit ()
 void connect (mixed $persistent)
 string convert_boolean_syntax (string $sql)
 integer current_sequencevalue (string $sequencename, string $table, string $column)
 mixed db_value_from_bool (boolean $boolvalue)
 void disconnect ()
 void errormessage (mixed $rid)
 void escape_string (mixed $str)
 void fetch_array (mixed $rid, mixed $rowno)
 void fetch_row (mixed $rid, mixed $rowno)
 void freeresult (mixed $rid)
 void lock (mixed $tablelist, mixed $mode)
 integer next_sequencevalue (string $sequencename, string $table, string $column)
 void numrows (mixed $rid)
 void query (mixed $sql)
 boolean rollback ()
 void set_char_encoding (mixed $encoding)
 void set_datestyle (mixed $datestyle)
 void set_sequencevalue (mixed $newval, mixed $sequencename, mixed $table, mixed $column)
 string SQL (pointer $sqlquery)
 void unescape_string (mixed $str)
Variables
mixed $connected = false (line 603)

Flag true if database was connected ok

mixed $datestyle = "UNICODE" (line 599)

The database internal date format/style

mixed $dbid = false (line 611)

Unique identifier for database access

mixed $enc = "" (line 601)

The database character encoding

mixed $executable_sql = "" (line 615)

The SQL statement last executed on this database. This

mixed $host = "" (line 591)

Host server of this database

mixed $name = "" (line 589)

Name of this database

mixed $passwd = "" (line 597)

Default password to connect as

mixed $persistent = false (line 608)

True if we want a persistent connection

mixed $port = 0 (line 593)

Port to access it via TCP

mixed $rid (line 619)

The result ID last returned by a query on this DB. Also

mixed $timer (line 622)

Microtimer for query execute timing

mixed $type = "" (line 587)

Type of database eg: "postgres", "mssql_server"..

mixed $user = "" (line 595)

Default user to connect as

Methods
Constructor database (line 634)

Constructor

database database ([string $name = ""], [string $user = ""], [string $passwd = ""], [string $host = ""], integer $port, [string $enc = ""], [string $datestyle = ""])
  • string $name: The database name
  • string $user: The username of user who can access the database
  • string $passwd: The user password which can access the database
  • string $host: The hostname of the machine running the database
  • integer $port: The port number of the database server
  • string $enc: The database character encoding (database dependent)
  • string $datestyle: The database date style (eg. 'ISO')
affectedrows (line 728)

This method must be defined in the child class.

  • abstract:
void affectedrows (mixed $rid)
begin_transaction (line 763)

Start a new database transaction.

  • return: Whether transaction was started or not
boolean begin_transaction ()
bool_from_db_value (line 790)

Return a Php boolean from a database field value. The database field is expected to be a container of some form of logical value. Here is where we convert it according to the current database.

  • return: The boolean value derived from the field value
boolean bool_from_db_value (mixed $dbvalue)
  • mixed $dbvalue: The value from the database field to convert
commit (line 771)

Commit the currently open database transaction.

  • return: Whether the commit succeeded or not
boolean commit ()
connect (line 658)

This method must be defined in the child class.

  • abstract:
void connect (mixed $persistent)
convert_boolean_syntax (line 953)

Make conversions of boolean syntax found in the SQL string and return the 'standardised' SQL. This assumes that Axyl SQL will be written in the form 'WHERE foo=TRUE'.

  • return: The converted SQL string
string convert_boolean_syntax (string $sql)
  • string $sql: SQL string to make conversions in
current_sequencevalue (line 812)

Return the current sequence value, given a sequence name, the table and the field it applies to.

  • return: The current sequence value
integer current_sequencevalue (string $sequencename, string $table, string $column)
  • string $sequencename: The name of the sequence to use
  • string $table: The name of the table the sequence is for
  • string $column: The name of the table column the sequence is for
db_value_from_bool (line 800)

Return a suitable database field value to contain the value for the given boolean.

  • return: The value suitable for the database field
mixed db_value_from_bool (boolean $boolvalue)
  • boolean $boolvalue: The boolean value to convert
disconnect (line 665)

This method must be defined in the child class.

  • abstract:
void disconnect ()
errormessage (line 741)

This method must be defined in the child class.

  • abstract:
void errormessage (mixed $rid)
escape_string (line 866)

This method may be over-ridden in the child class. The default is to apply a rather simplistic SQL-standard transformation of single quote to doubled-up single-quote ' --> ''.

void escape_string (mixed $str)
fetch_array (line 755)

This method must be defined in the child class.

  • abstract:
void fetch_array (mixed $rid, mixed $rowno)
fetch_row (line 748)

This method must be defined in the child class.

  • abstract:
void fetch_row (mixed $rid, mixed $rowno)
freeresult (line 735)

This method must be defined in the child class.

  • abstract:
void freeresult (mixed $rid)
lock (line 858)

This method must be defined in the child class.

  • abstract:
void lock (mixed $tablelist, mixed $mode)
next_sequencevalue (line 830)

Return the next sequence value, given a sequence name, the table and the field it applies to.

  • return: The next sequence value
integer next_sequencevalue (string $sequencename, string $table, string $column)
  • string $sequencename: The name of the sequence to use
  • string $table: The name of the table the sequence is for
  • string $column: The name of the table column the sequence is for
numrows (line 721)

This method must be defined in the child class.

  • abstract:
void numrows (mixed $rid)
query (line 671)

This method must be defined in the child class.

  • abstract:
void query (mixed $sql)
rollback (line 779)

Rollback the currently open database transaction.

  • return: Whether the rollback succeeded or not
boolean rollback ()
set_char_encoding (line 851)

This method must be defined in the child class.

  • abstract:
void set_char_encoding (mixed $encoding)
set_datestyle (line 844)

This method must be defined in the child class.

  • abstract:
void set_datestyle (mixed $datestyle)
set_sequencevalue (line 837)

This method must be defined in the child class.

  • abstract:
void set_sequencevalue (mixed $newval, mixed $sequencename, mixed $table, mixed $column)
SQL (line 886)

Given an Axyl SQL query object, build the SQL string from it in suitable format for the currently connected database server.

  • return: The SQL string built from the query object
string SQL (pointer $sqlquery)
  • pointer $sqlquery: Pointer to an Axyl query object
unescape_string (line 876)

This method may be over-ridden in the child class. The default action is to simply do nothing.

void unescape_string (mixed $str)

Documentation generated by phpDocumentor 1.3.0RC3