Class datasources

Description

Datasources A datasources class is just a bunch of databases. If you want to access a database, register it in here first, then you can select it to perform queries on later.

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


	
			
Variable Summary
Method Summary
 datasources datasources ()
 void add_database (string $dbtype, string $name, [string $user = ""], [string $passwd = ""], [string $host = ""], integer $port, [string $enc = ""], [string $datestyle = ""], [boolean $default = false])
 integer affectedrows (resource $rid)
 boolean begin_transaction ()
 boolean bool_from_db_value (mixed $dbvalue)
 boolean commit ()
 boolean connect ([boolean $persistent = NOT_PERSISTENT])
 boolean connected ([string $db_name = ""])
 integer current_sequencevalue (string $sequencename, string $table, string $column)
 resource dbid ([string $db_name = ""])
 string dbtype ([string $db_name = ""])
 mixed db_value_from_bool (boolean $boolvalue)
 void disconnect ()
 string errormessage ()
 array fetch_array (resource $rid, integer $rowno)
 array fetch_row (resource $rid, integer $rowno)
 void freeresult (resource $rid)
 string get_last_sql ()
 boolean lock (string $tablelist, string $mode)
 integer next_sequencevalue (string $sequencename, string $table, string $column)
 integer numrows (resource $rid)
 resource query (string $sql)
 boolean rollback ()
 resource select ([string $db_name = ""])
 boolean set_char_encoding (string $encoding)
 boolean set_datestyle (string $datestyle)
 void set_default (string $db_name)
 boolean set_sequencevalue (integer $newval, string $sequencename, string $table, string $column)
 string SQL (object $sqlquery)
Variables
mixed $database (line 50)

An array of database objects. All databases we can use as datasources

mixed $db_name_default = "" (line 52)

Default database name

mixed $db_name_selected = "" (line 54)

Name of currently selected database

Methods
Constructor datasources (line 57)

Constructor

datasources datasources ()
add_database (line 73)

Constructor Add a new base to our list of datasources. The dbtype and the name are the only mandatory parameters.

void add_database (string $dbtype, string $name, [string $user = ""], [string $passwd = ""], [string $host = ""], integer $port, [string $enc = ""], [string $datestyle = ""], [boolean $default = false])
  • string $dbtype: The type of database eg: 'postgres', 'mssql' etc.
  • string $name: The name of the database
  • string $user: Name of a user who can access the database
  • string $passwd: The password the user can access the database with
  • string $host: The hostname of the machine running the database (TCP/IP)
  • integer $port: The port number of the database server
  • string $enc: The database character encoding
  • string $datestyle: The database date style
  • boolean $default: True if the database is the default database
affectedrows (line 303)

Return the number of rows affected by a query.

  • return: The number of rows affected by the query
integer affectedrows (resource $rid)
  • resource $rid: The resource ID for the executed query
begin_transaction (line 368)

Start a database transaction

  • return: Flag indicating successful start of transaction
boolean begin_transaction ()
bool_from_db_value (line 408)

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 380)

Commit open database transaction

  • return: Flag indicating successful commit of transaction
boolean commit ()
connect (line 225)

Connects to the database which has been selected in the mode specified, or non-peristent otherwise.

  • return: Whether database connection was successful
boolean connect ([boolean $persistent = NOT_PERSISTENT])
  • boolean $persistent: Whether to connect persistently or not
connected (line 208)

Returns connected status of named database, or the currently selected one if no name given.

  • return: Database connection status true or false
boolean connected ([string $db_name = ""])
  • string $db_name: The name of the database
current_sequencevalue (line 438)

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
dbid (line 173)

Returns the database resource ID of the given database name.

If dbname is not given, returns ID of currently selected DB.

  • return: Database resource ID
resource dbid ([string $db_name = ""])
  • string $db_name: The name of the database
dbtype (line 191)

Returns the database type of the given database name.

If dbname is not given, returns type of DB currently selected.

  • return: Database type string
string dbtype ([string $db_name = ""])
  • string $db_name: The name of the database
db_value_from_bool (line 422)

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 250)

Disconnect the currently selected database.

void disconnect ()
errormessage (line 326)

Return the last error message.

  • return: The last error message which was generated
string errormessage ()
fetch_array (line 356)

Return the specified row, as an associative array of fields in a fieldname => value format.

  • return: Associative array of field values
array fetch_array (resource $rid, integer $rowno)
  • resource $rid: The resource ID for the executed query
  • integer $rowno: Row number (zero-based) of row to return
fetch_row (line 341)

Return the specified row, as a standard (enumerated) array of field values.

  • return: Enumerated array of field values
array fetch_row (resource $rid, integer $rowno)
  • resource $rid: The resource ID for the executed query
  • integer $rowno: Row number (zero-based) of row to return
freeresult (line 316)

Free the result of a query

void freeresult (resource $rid)
  • resource $rid: The query resource ID
get_last_sql (line 276)

Returns SQL statement most recently executed on the current DB.

NB: the format and/or content of this SQL may differ from the SQL originally submitted, due to database-dependent transformations, hence the usefulness of this method.

  • return: The SQL statement last executed on current database.
string get_last_sql ()
lock (line 515)

General-purpose lock method. We pass the elements of the lock, which is the list of tables to lock, and the lock-mode. The latter mode is database-specific, and therefore flexible.

  • return: Whether the setting succeeded or not
boolean lock (string $tablelist, string $mode)
  • string $tablelist: List of tables to lock, comma-delimited
  • string $mode: Databes-specific locking-mode or type
next_sequencevalue (line 454)

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 289)

Return the number of rows returned by a SELECT query.

  • return: The number of rows returned by the query
integer numrows (resource $rid)
  • resource $rid: The resource ID for the executed query
query (line 261)

Execute a query on the connected database.

  • return: A database query resource ID, or false if query failed
resource query (string $sql)
  • string $sql: The SQL query to execute on the database
rollback (line 393)

Roll back the current database transaction. All queries executed as part of the open transaction will be rolled back.

  • return: Flag indicating successful rollback of transaction
boolean rollback ()
select (line 127)

This will connect it if it isn't already connected. Calling this with no database name will select the default one. Returns the database unique identifier, or false if none was selected.

  • return: The database resource ID
resource select ([string $db_name = ""])
  • string $db_name: The name of the database to select
set_char_encoding (line 499)

Set the database character encoding. This affects the encoding of characters in the database.

  • return: Whether the setting succeeded or not
boolean set_char_encoding (string $encoding)
  • string $encoding: The character encoding to set
set_datestyle (line 485)

Set the database date style. This affect the format that dates will be displayed in, and the format they are submitted in.

  • return: Whether the setting succeeded or not
boolean set_datestyle (string $datestyle)
  • string $datestyle: The date style code to set
set_default (line 160)

Internal function to set the name of the default database.

The database must exist as a defined database already.

void set_default (string $db_name)
  • string $db_name: The name of the database
set_sequencevalue (line 471)

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

  • return: Whether the assignment succeeded or not
boolean set_sequencevalue (integer $newval, string $sequencename, string $table, string $column)
  • integer $newval: The sequence value to set
  • 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
SQL (line 529)

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 (object $sqlquery)
  • object $sqlquery: An Axyl query object

Documentation generated by phpDocumentor 1.3.0RC3