xPDO __construct(
$dsn, [
$username = ''], [
$password = ''], [
$tablePrefix = ''], [
$driverOptions = null]
)
|
|
Parameters:
|
|
$dsn: |
|
|
|
$username: |
|
|
|
$password: |
|
|
|
$tablePrefix: |
|
|
|
$driverOptions: |
|
xPDO xPDO(
mixed
$dsn, [string
$username = ''], [string
$password = ''], [string
$tablePrefix = ''], [mixed
$driverOptions = null]
)
|
|
The xPDO Constructor.
This method is used to create a new xPDO object with a connection to a specific database container.
Parameters:
|
mixed |
$dsn: |
A valid DSN connection string. |
|
string |
$username: |
The database username with proper permissions. |
|
string |
$password: |
The password for the database user. |
|
string |
$tablePrefix: |
A prefix applied to all database container names, to isolate multiple installations or conflicting table names that might need to coexist in a single database container. |
|
mixed |
$driverOptions: |
Driver-specific PDO options. |
void connect(
[
$driverOptions = array ()]
)
|
|
Parameters:
void fromCache(
$signature, [
$class = ''], [
$format = 'php']
)
|
|
Parameters:
|
|
$signature: |
|
|
|
$class: |
|
|
|
$format: |
|
void fromJSON(
$src, [
$asArray = true]
)
|
|
Parameters:
array getAggregates(
string
$className
)
|
|
Gets a collection of aggregate foreign key relationship definitions.
Parameters:
|
string |
$className: |
The fully-qualified name of the class. |
API Tags:
| Return: | An array of aggregate foreign key relationship definitions. |
array getAncestry(
string
$className, [boolean
$includeSelf = true]
)
|
|
Retrieves the complete ancestry for a class.
Parameters:
|
string |
$className: |
className The name of the class. |
|
boolean |
$includeSelf: |
includeSelf Determines if the specified class should be included in the resulting array. |
API Tags:
| Return: | An array of string class names representing the class hierarchy, or an empty array if unsuccessful. |
void getAttribute(
$attribute
)
|
|
Parameters:
API Tags:
object The getCacheManager(
[string
$class = 'cache.xPDOCacheManager'], [string
$path = XPDO_CORE_PATH]
)
|
|
Gets the xPDOCacheManager instance.
This class is responsible for handling all types of caching operations for the xPDO core.
Parameters:
|
string |
$class: |
Optional name of a derivative xPDOCacheManager class. |
|
string |
$path: |
Optional root path for looking up the $class. |
API Tags:
| Return: | xPDOCacheManager for this xPDO instance. |
Gets the absolute path to the cache directory.
API Tags:
| Return: | The full cache directory path. |
array|null getCollection(
string
$className, [object|array|string
$criteria = null], [mixed
$cacheFlag = false]
)
|
|
Retrieves a collection of xPDOObjects by the specified xPDOCriteria.
Parameters:
|
string |
$className: |
Name of the class to search for instances of. |
|
object|array|string |
$criteria: |
An xPDOCriteria object or an array search expression. |
|
mixed |
$cacheFlag: |
If an integer value is provided, this specifies the time to live in the result set cache; if cacheFlag === false, caching is ignored for the collection and if cacheFlag === true, the objects will live in cache until flushed by another process. |
API Tags:
| Return: | An array of class instances retrieved. |
void getCollectionGraph(
string
$className, string|array
$graph, [mixed
$criteria = null], [boolean
$cacheFlag = false]
)
|
|
Retrieves a collection of xPDOObject instances with related objects.
Parameters:
|
string |
$className: |
The name of the class to return a collection of. |
|
string|array |
$graph: |
A related object graph in array or JSON format, e.g. array('ClassName'=>array('relationKey'=>array())) or '{"ClassName":{"relationKey":{}}}' |
|
mixed |
$criteria: |
A valid xPDOCriteria instance or condition string. |
|
boolean |
$cacheFlag: |
Indicates if the result set should be cached. |
array getComposites(
string
$className
)
|
|
Gets a collection of composite foreign key relationship definitions.
Parameters:
|
string |
$className: |
The fully-qualified name of the class. |
API Tags:
| Return: | An array of composite foreign key relationship definitions. |
void getCount(
string
$className, [mixed
$criteria = null]
)
|
|
Retrieves a count of xPDOObjects by the specified xPDOCriteria.
Parameters:
|
string |
$className: |
Class of xPDOObject to count instances of. |
|
mixed |
$criteria: |
Any valid xPDOCriteria object or expression. |
xPDOCriteria getCriteria(
string
$className, [string
$type = null], [
$cacheFlag = true]
)
|
|
Gets criteria pre-defined in an xPDOObject class metadata definition.
Parameters:
|
string |
$className: |
The class to get predefined criteria for. |
|
string |
$type: |
The type of criteria to get (you can define any type you want, but 'object' and 'collection' are the typical criteria for retrieving single and multiple instances of an object). |
|
|
$cacheFlag: |
|
API Tags:
| Return: | A criteria object or null if not found. |
Information Tags:
| Todo: | Define callback functions as an alternative to retreiving criteria sql and/or bindings from the metadata. |
| Todo: | Move quotable operators to the db specific xPDOObject implementation. |
Returns the debug state for the XPDO connection.
API Tags:
| Return: | The current debug state for the connection, true for on, false for off. |
array getFieldMeta(
string
$className
)
|
|
Gets a list of field (or column) definitions for an object by class name.
These definitions are used by the objects themselves to build their own meta data based on class inheritence.
Parameters:
|
string |
$className: |
The name of the class to lookup fields meta data for. |
API Tags:
| Return: | An array featuring field names as the array keys, and arrays of metadata information as the array values; empty array is returned if unsuccessful. |
array getFields(
string
$className
)
|
|
Gets a list of fields (or columns) for an object by class name.
This includes default values for each field and is used by the objects themselves to build their initial attributes based on class inheritence.
Parameters:
|
string |
$className: |
The name of the class to lookup fields for. |
API Tags:
| Return: | An array featuring field names as the array keys, and default field values as the array values; empty array is returned if unsuccessful. |
void getFKDefinition(
$parentClass,
$alias
)
|
|
Parameters:
object|null getManager(
)
|
|
Gets the manager class for this XPDO connection.
The manager class can perform operations such as creating or altering table structures, creating data containers, generating custom persistence classes, and other advanced operations that do not need to be loaded frequently.
API Tags:
| Return: | A manager instance for the XPDO connection, or null if a manager class can not be instantiated. |
object|null getObject(
string
$className, [mixed
$criteria = null], [mixed
$cacheFlag = false]
)
|
|
Retrieves a single object instance by the specified criteria.
The criteria can be a primary key value, and array of primary key values (for multiple primary key objects) or an xPDOCriteria object. If no $criteria parameter is specified, no class is found, or an object cannot be located by the supplied criteria, null is returned.
Parameters:
|
string |
$className: |
Name of the class to get an instance of. |
|
mixed |
$criteria: |
Primary key of the record or a xPDOCriteria object. |
|
mixed |
$cacheFlag: |
If an integer value is provided, this specifies the time to live in the object cache; if cacheFlag === false, caching is ignored for the object and if cacheFlag === true, the object will live in cache indefinitely. |
API Tags:
| Return: | An instance of the class, or null if it could not be instantiated. |
void getObjectGraph(
string
$className, string|array
$graph, [mixed
$criteria = null], [boolean
$cacheFlag = false]
)
|
|
Retrieves an xPDOObject instance with specified related objects.
Parameters:
|
string |
$className: |
The name of the class to return an instance of. |
|
string|array |
$graph: |
A related object graph in array or JSON format, e.g. array('ClassName'=>array('relationKey'=>array())) or {ClassName:{relationKey:{}}} |
|
mixed |
$criteria: |
A valid xPDOCriteria instance or condition string. |
|
boolean |
$cacheFlag: |
Indicates if the result set should be cached. |
mixed getPK(
string
$className
)
|
|
Gets the primary key field(s) for a class.
Parameters:
|
string |
$className: |
The name of the class to lookup the primary key for. |
API Tags:
| Return: | The name of the field representing a class instance primary key, an array of key names for compound primary keys, or null if no primary key is found or defined for the class. |
string getPKType(
string
$className, [
$pk = false]
)
|
|
Gets the type of primary key field for a class.
Parameters:
|
string |
$className: |
className The name of the class to lookup the primary key type for. |
|
|
$pk: |
|
API Tags:
| Return: | The type of the field representing a class instance primary key, or null if no primary key is found or defined for the class. |
Information Tags:
| Todo: | Refactor method to return array of types rather than compound! |
string getSelectColumns(
string
$className, [string
$tableAlias = ''], [string
$columnPrefix = ''], [array
$columns = array ()], [boolean
$exclude = false]
)
|
|
Gets select columns from a specific class for building a query.
Parameters:
|
string |
$className: |
The name of the class to build the column list from. |
|
string |
$tableAlias: |
An optional alias for the class table, to be used in complex queries with multiple tables. |
|
string |
$columnPrefix: |
An optional string with which to prefix the columns returned, to avoid name collisions in return columns. |
|
array |
$columns: |
An optional array of columns to include. |
|
boolean |
$exclude: |
If true, will exclude columns in the previous parameter, instead of including them. |
API Tags:
| Return: | A valid SQL string of column names for a SELECT statement. |
string getTableMeta(
string
$className
)
|
|
Gets the actual run-time table metadata from a specified class name.
Parameters:
|
string |
$className: |
The name of the class to lookup a table name for. |
API Tags:
| Return: | The table meta data for the class, or null if unsuccessful. |
string getTableName(
string
$className, [boolean
$includeDb = false]
)
|
|
Gets the actual run-time table name from a specified class name.
Parameters:
|
string |
$className: |
The name of the class to lookup a table name for. |
|
boolean |
$includeDb: |
Qualify the table name with the database name. |
API Tags:
| Return: | The table name for the class, or null if unsuccessful. |
string|boolean loadClass(
string
$fqn, [
$path = ''], [
$ignorePkg = false], [
$transient = false]
)
|
|
Load a class by fully qualified name.
The $fqn should in the format:
dir_a.dir_b.dir_c.classname
which will translate to:
XPDO_CORE_PATH/om/dir_a/dir_b/dir_c/dbtype/classname.class.php
Parameters:
|
string |
$fqn: |
The fully-qualified name of the class to load. |
|
|
$path: |
|
|
|
$ignorePkg: |
|
|
|
$transient: |
|
API Tags:
| Return: | The actual classname if successful, or false if not. |
object|null newObject(
string
$className, [array
$fields = array ()]
)
|
|
Creates a new instance of a specified class.
All new objects created with this method are transient until saved for the first time.
Parameters:
|
string |
$className: |
Name of the class to get a new instance of. |
|
array |
$fields: |
An associated array of field names/values to populate the object with. |
API Tags:
| Return: | A new instance of the specified class, or null if a new object could not be instantiated. |
void newQuery(
$class, [
$criteria = null], [
$cacheFlag = true]
)
|
|
Parameters:
|
|
$class: |
|
|
|
$criteria: |
|
|
|
$cacheFlag: |
|
array parseDSN(
string
$string
)
|
|
Parses a DSN and returns an array of the connection details.
Parameters:
|
string |
$string: |
The DSN to parse. |
API Tags:
| Return: | An array of connection details from the DSN. |
Information Tags:
| Todo: | Have this method handle all methods of DSN specification as handled by latest native PDO implementation. |
void prepare(
$statement, [
$driver_options = array ()]
)
|
|
Parameters:
|
|
$statement: |
|
|
|
$driver_options: |
|
API Tags:
void quote(
$string, [
$parameter_type = PDO_PARAM_STR]
)
|
|
Parameters:
|
|
$string: |
|
|
|
$parameter_type: |
|
API Tags:
void setAttribute(
$attribute,
$value
)
|
|
Parameters:
API Tags:
void setDebug(
[boolean
$v = true]
)
|
|
Sets the debug state for the XPDO connection.
Parameters:
|
boolean |
$v: |
The debug status, true for on, false for off. |
void setLogLevel(
[integer
$level = XPDO_LOG_LEVEL_FATAL]
)
|
|
Sets the logging level state for the XPDO instance.
Parameters:
|
integer |
$level: |
The logging level to switch to. |
void setLogTarget(
[
$target = 'ECHO']
)
|
|
Parameters:
void setPackage(
[string
$pkg = ''], [string
$path = '']
)
|
|
Sets a specific model package to use when looking up classes.
This package is of the form package.subpackage.subsubpackage and will be added to the beginning of every XPDO class that is referenced in XPDO methods such as loadClass(), getObject(), getCollection(), getOne(), addOne(), etc.
Parameters:
|
string |
$pkg: |
A package name to use when looking up classes in XPDO. |
|
string |
$path: |
The root path for looking up classes in this package. |
void toCache(
$signature,
$object, [
$lifetime = 0], [
$compressed = false]
)
|
|
Parameters:
|
|
$signature: |
|
|
|
$object: |
|
|
|
$lifetime: |
|
|
|
$compressed: |
|
string _getFullTableName(
string
$baseTableName, [boolean
$includeDb = false]
)
|
|
Adds the table prefix, and optionally database name, to a given table.
Parameters:
|
string |
$baseTableName: |
The table name as specified in the object model. |
|
boolean |
$includeDb: |
Qualify the table name with the database name. |
API Tags:
| Return: | The fully-qualified and quoted table name for the |
string _getLogLevel(
integer
$level
)
|
|
Gets a logging level as a string representation.
Parameters:
|
integer |
$level: |
The logging level to retrieve a string for. |
API Tags:
| Return: | The string representation of a valid logging level. |
void _log(
integer
$level, string
$msg, [string
$target = ''], [
$def = ''], [
$file = ''], [
$line = '']
)
|
|
Log a message as appropriate for the level and target.
Parameters:
|
integer |
$level: |
The level of the logged message. |
|
string |
$msg: |
The message to log. |
|
string |
$target: |
The logging target. |
|
|
$def: |
|
|
|
$file: |
|
|
|
$line: |
|