Constructor
datasources
datasources
()
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
Return the number of rows affected by a query.
integer
affectedrows
(resource $rid)
-
resource
$rid: The resource ID for the executed query
Start a database transaction
boolean
begin_transaction
()
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.
boolean
bool_from_db_value
(mixed $dbvalue)
-
mixed
$dbvalue: The value from the database field to convert
Commit open database transaction
boolean
commit
()
Connects to the database which has been selected in the mode specified, or non-peristent otherwise.
boolean
connect
([boolean $persistent = NOT_PERSISTENT])
-
boolean
$persistent: Whether to connect persistently or not
Returns connected status of named database, or the currently selected one if no name given.
boolean
connected
([string $db_name = ""])
-
string
$db_name: The name of the database
Return the current sequence value, given a sequence name, the table and the field it applies to.
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
Returns the database resource ID of the given database name.
If dbname is not given, returns ID of currently selected DB.
resource
dbid
([string $db_name = ""])
-
string
$db_name: The name of the database
Returns the database type of the given database name.
If dbname is not given, returns type of DB currently selected.
string
dbtype
([string $db_name = ""])
-
string
$db_name: The name of the database
Return a suitable database field value to contain the value for the given boolean.
mixed
db_value_from_bool
(boolean $boolvalue)
-
boolean
$boolvalue: The boolean value to convert
Disconnect the currently selected database.
void
disconnect
()
Return the last error message.
string
errormessage
()
Used to escape particular characters (typically the single quote) so that they can form part of the database data, rather than being interpreted as command syntax.
string
escape_string
([string $str = ""])
Return the specified row, as an associative array of fields in a fieldname => value format.
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
Return the specified row, as a standard (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
Free the result of a query
void
freeresult
(resource $rid)
-
resource
$rid: The query resource ID
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.
string
get_last_sql
()
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.
boolean
lock
(string $tablelist, string $mode)
-
string
$tablelist: List of tables to lock, comma-delimited
-
string
$mode: Databes-specific locking-mode or type
Return the next sequence value, given a sequence name, the table and the field it applies to.
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
Return the number of rows returned by a SELECT query.
integer
numrows
(resource $rid)
-
resource
$rid: The resource ID for the executed query
Execute a query on the connected database.
resource
query
(string $sql)
-
string
$sql: The SQL query to execute on the database
Roll back the current database transaction. All queries executed as part of the open transaction will be rolled back.
boolean
rollback
()
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.
resource
select
([string $db_name = ""])
-
string
$db_name: The name of the database to select
Set the database character encoding. This affects the encoding of characters in the database.
boolean
set_char_encoding
(string $encoding)
-
string
$encoding: The character encoding to set
Set the database date style. This affect the format that dates will be displayed in, and the format they are submitted in.
boolean
set_datestyle
(string $datestyle)
-
string
$datestyle: The date style code to set
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 the sequence value, given a sequence name, the table and the field it applies to.
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
Given an Axyl SQL query object, build the SQL string from it in suitable format for the currently connected database server.
string
SQL
(object $sqlquery)
-
object
$sqlquery: An Axyl query object
Used to unescape escaped characters (typically the single quote) so that they are as they were before having the escape_string() method applied.
Note that some databases do not need this to be done - they unescape escaped content when data is returned.
string
unescape_string
([string $str = ""])