Class AwlDBDialect
The AwlDBDialect class handles support for different SQL dialects
This subpackage provides dialect specific support for PostgreSQL, and
may, over time, be extended to provide support for other SQL dialects.
If you are looking for the place to add support for other SQL dialects,
this is the class that you should be looking at. You might also look at
the AwlDatabase class which extends this one, but these are the core
capabilities which most probably need attention.
Methods summary
public
|
#
__construct( string $connection_string, string $dbuser = null, string $dbpass = null, array $options = null )
Parses the connection string to ascertain the database dialect. Returns true if the dialect is supported
and fails if the dialect is not supported. All code to support any given database should be within in an
external include.
Parses the connection string to ascertain the database dialect. Returns true if the dialect is supported
and fails if the dialect is not supported. All code to support any given database should be within in an
external include.
The database will be opened.
Parameters
- $connection_string
- The PDO connection string, in all it's glory
- $dbuser
- The database username to connect as
- $dbpass
- The database password to connect with
- $options
- An array of driver options
|
public
|
#
SetSearchPath( $search_path = null )
Sets the current search path for the database.
Sets the current search path for the database.
|
public
|
#
GetVersion( handle $pdo,… )
Sets the current search path for the database.
Sets the current search path for the database.
Parameters
- $pdo,…
- A handle to an opened database
|
public
|
#
GetFields( string $tablename_string )
Returns the SQL for the current database dialect which will return a two-column resultset containing a
list of fields and their associated data types.
Returns the SQL for the current database dialect which will return a two-column resultset containing a
list of fields and their associated data types.
Parameters
- $tablename_string
- The name of the table we want fields from
|
public
|
#
TranslateSQL( $sql_string )
Translates the given SQL string into a form that will hopefully work for this database dialect. This hook
is intended to be used by developers to provide support for differences in database operation by translating
the query string in an arbitrary way, such as through a file or database lookup.
Translates the given SQL string into a form that will hopefully work for this database dialect. This hook
is intended to be used by developers to provide support for differences in database operation by translating
the query string in an arbitrary way, such as through a file or database lookup.
The actual translation to other SQL dialects will be application-specific, so that any routines
called by this will be external to this library, or will use resources loaded from some source
external to this library.
The application developer is expected to use this functionality to solve harder translation problems,
but is less likely to call this directly, hopefully switching ->Prepare to ->PrepareTranslated in those
cases, and then adding that statement to whatever SQL translation infrastructure is in place.
|
public
|
#
Quote( mixed $value, string $value_type = null )
Returns $value escaped in an appropriate way for this database dialect.
Returns $value escaped in an appropriate way for this database dialect.
Parameters
- $value
- The value to be escaped
- $value_type
The type of escaping desired. If blank this will
be worked out from the type of the $value. The special type
of 'identifier' can also be used for escaping of SQL identifiers.
|
public
The
|
#
ReplaceParameters( )
Replaces query parameters with appropriately escaped substitutions.
Replaces query parameters with appropriately escaped substitutions.
The function takes a variable number of arguments, the first is the
SQL string, with replaceable '?' characters (a la DBI). The subsequent
parameters being the values to replace into the SQL string.
The values passed to the routine are analyzed for type, and quoted if
they appear to need quoting. This can go wrong for (e.g.) NULL or
other special SQL values which are not straightforwardly identifiable
as needing quoting (or not). In such cases the parameter can be forced
to be inserted unquoted by passing it as "array( 'plain' => $param )".
Returns
The built query string
|
public
The
|
#
ReplaceNamedParameters( )
Replaces named query parameters of the form :name with appropriately
escaped substitutions.
Replaces named query parameters of the form :name with appropriately
escaped substitutions.
The function takes a variable number of arguments, the first is the
SQL string, with replaceable ':name' characters (a la DBI). The
subsequent parameters being the values to replace into the SQL string.
The values passed to the routine are analyzed for type, and quoted if
they appear to need quoting. This can go wrong for (e.g.) NULL or
other special SQL values which are not straightforwardly identifiable
as needing quoting (or not).
Returns
The built query string
|
Constants summary
string |
HttpDateFormat
A PostgreSQL Date Format string suitable for returning HTTP (RFC2068) dates
Preferred is "Sun, 06 Nov 1994 08:49:37 GMT" so we do that.
A PostgreSQL Date Format string suitable for returning HTTP (RFC2068) dates
Preferred is "Sun, 06 Nov 1994 08:49:37 GMT" so we do that.
|
#
"'Dy, DD Mon IYYY HH24:MI:SS \"GMT\"'"
|
string |
SqlDateFormat
A PostgreSQL Date Format string suitable for returning iCal dates
A PostgreSQL Date Format string suitable for returning iCal dates
|
#
"'YYYYMMDD\"T\"HH24MISS'"
|
string |
SqlUTCFormat
A PostgreSQL Date Format string suitable for returning dates which
have been cast to UTC
A PostgreSQL Date Format string suitable for returning dates which
have been cast to UTC
|
#
"'YYYYMMDD\"T\"HH24MISS\"Z\"'"
|
string |
SqlDurationFormat
A PostgreSQL Date Format string suitable for returning iCal durations
- this doesn't work for negative intervals, but events should not have such!
A PostgreSQL Date Format string suitable for returning iCal durations - this doesn't work for negative intervals, but events should not have such!
|
#
"'\"PT\"HH24\"H\"MI\"M\"'"
|
Properties summary
protected
|
$dialect
Holds the name of the database dialect
Holds the name of the database dialect
|
|
protected
|
$db
Holds the PDO database connection
Holds the PDO database connection
|
|