Andrew's Web Libraries (AWL)
|
Public Member Functions | |
__construct ( $connection_string, $dbuser=null, $dbpass=null, $options=null) | |
SetSearchPath ( $search_path=null) | |
GetVersion () | |
GetFields ( $tablename_string) | |
TranslateSQL ( $sql_string) | |
Quote ( $value, $value_type=null) | |
ReplaceParameters () | |
ReplaceNamedParameters () | |
Public Attributes | |
const | HttpDateFormat = "'Dy, DD Mon IYYY HH24:MI:SS \"GMT\"'" |
const | SqlDateFormat = "'YYYYMMDD\"T\"HH24MISS'" |
const | SqlUTCFormat = "'YYYYMMDD\"T\"HH24MISS\"Z\"'" |
const | SqlDurationFormat = "'\"PT\"HH24\"H\"MI\"M\"'" |
Protected Attributes | |
$dialect | |
$db | |
Private Attributes | |
$version | |
Definition at line 33 of file AwlDBDialect.php.
AwlDBDialect::__construct | ( | $connection_string, | |
$dbuser = null , |
|||
$dbpass = null , |
|||
$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.
The database will be opened.
string | $connection_string | The PDO connection string, in all it's glory |
string | $dbuser | The database username to connect as |
string | $dbpass | The database password to connect with |
array | $options | An array of driver options |
Definition at line 90 of file AwlDBDialect.php.
AwlDBDialect::GetFields | ( | $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.
string | $tablename_string | The name of the table we want fields from |
Definition at line 160 of file AwlDBDialect.php.
AwlDBDialect::GetVersion | ( | ) |
Sets the current search path for the database.
handle | $pdo | A handle to an opened database |
Definition at line 131 of file AwlDBDialect.php.
AwlDBDialect::Quote | ( | $value, | |
$value_type = null |
|||
) |
Returns $value escaped in an appropriate way for this database dialect.
mixed | $value | The value to be escaped |
string | $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. |
: Someone should confirm this is correct for MySql
PDO handling of \ seems unreliable. We can't use $$string$$ syntax because it also doesn't work. We need to replace ':' so no other named parameters accidentally rewrite the content inside this string(!), and since we're using ' to delimit the string we need SQL92-compliant '' to replace it.
PostgreSQL wants to know when a string might contain escapes, and if this happens old versions of PHP::PDO need the ? escaped as well...
Definition at line 213 of file AwlDBDialect.php.
AwlDBDialect::ReplaceNamedParameters | ( | ) |
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).
string | The query string with replacable ':name' identifiers |
mixed | A ':name' => 'value' hash of values to replace into the SQL string. |
If the first argument is an array we treat that as our arguments instead
Definition at line 371 of file AwlDBDialect.php.
AwlDBDialect::ReplaceParameters | ( | ) |
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 )".
string | The query string with replacable '?' characters. |
mixed | The values to replace into the SQL string. |
If the first argument is an array we treat that as our arguments instead
We only split into a maximum of $argc chunks. Any leftover ? will remain in the string and may be replaced at Exec rather than Prepare. Scary!
Definition at line 315 of file AwlDBDialect.php.
AwlDBDialect::SetSearchPath | ( | $search_path = null | ) |
Sets the current search path for the database.
Definition at line 113 of file AwlDBDialect.php.
AwlDBDialect::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.
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.
Definition at line 199 of file AwlDBDialect.php.
|
protected |
Holds the PDO database connection
Definition at line 46 of file AwlDBDialect.php.
|
protected |
#+ private Holds the name of the database dialect
Definition at line 41 of file AwlDBDialect.php.
|
private |
Holds the version
Definition at line 51 of file AwlDBDialect.php.
const AwlDBDialect::HttpDateFormat = "'Dy, DD Mon IYYY HH24:MI:SS \"GMT\"'" |
#- 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.
Definition at line 59 of file AwlDBDialect.php.
const AwlDBDialect::SqlDateFormat = "'YYYYMMDD\"T\"HH24MISS'" |
A PostgreSQL Date Format string suitable for returning iCal dates
Definition at line 64 of file AwlDBDialect.php.
const AwlDBDialect::SqlDurationFormat = "'\"PT\"HH24\"H\"MI\"M\"'" |
A PostgreSQL Date Format string suitable for returning iCal durations
Definition at line 76 of file AwlDBDialect.php.
const AwlDBDialect::SqlUTCFormat = "'YYYYMMDD\"T\"HH24MISS\"Z\"'" |
A PostgreSQL Date Format string suitable for returning dates which have been cast to UTC
Definition at line 70 of file AwlDBDialect.php.