Class xPDO

Description

A wrapper for PDO that powers an object-relational data model.

xPDO provides centralized data access via a simple object-oriented API, to a defined data structure. It provides the de facto methods for connecting to a data source, getting persistence metadata for any class extended from the xPDOObject class (core or custom), loading data source managers when needed to manage table structures, and retrieving instances (or rows) of any object in the model.

Through various extensions, you can also reverse and forward engineer classes and metadata maps for xPDO, have classes, models, and properties maintain their own containers (databases, tables, columns, etc.) or changes to them, and much more.

Located in /xpdo.class.php (line 93)


	
			
Class Constant Summary
 OPT_BASE_CLASSES = 'base_classes'
 OPT_BASE_PACKAGES = 'base_packages'
 OPT_CACHE_COMPRESS = 'cache_compress'
 OPT_CACHE_DB = 'cache_db'
 OPT_CACHE_DB_COLLECTIONS = 'cache_db_collections'
 OPT_CACHE_DB_EXPIRES = 'cache_db_expires'
 OPT_CACHE_DB_HANDLER = 'cache_db_handler'
 OPT_CACHE_DB_OBJECTS_BY_PK = 'cache_db_objects_by_pk'
 OPT_CACHE_EXPIRES = 'cache_expires'
 OPT_CACHE_HANDLER = 'cache_handler'
 OPT_CACHE_KEY = 'cache_key'
 OPT_CACHE_PATH = 'cache_path'
 OPT_CALLBACK_ON_REMOVE = 'callback_on_remove'
 OPT_CALLBACK_ON_SAVE = 'callback_on_save'
 OPT_HYDRATE_ADHOC_FIELDS = 'hydrate_adhoc_fields'
 OPT_HYDRATE_FIELDS = 'hydrate_fields'
 OPT_HYDRATE_RELATED_OBJECTS = 'hydrate_related_objects'
 OPT_LOADER_CLASSES = 'loader_classes'
 OPT_ON_SET_STRIPSLASHES = 'on_set_stripslashes'
 OPT_SETUP = 'setup'
 OPT_TABLE_PREFIX = 'table_prefix'
 OPT_VALIDATE_ON_SAVE = 'validate_on_save'
 OPT_VALIDATOR_CLASS = 'validator_class'
 SCHEMA_VERSION = '1.1'
Variable Summary
Method Summary
 static array escSplit (string $char, string $str, [string $escToken = '`'], [integer $limit = 0])
 static array parseDSN (string $string)
 xPDO __construct (mixed $dsn, [string $username = ''], [string $password = ''], [array|string $options = array()], [mixed $driverOptions = null])
 void addDerivativeCriteria (string $className, xPDOCriteria $criteria)
 void addPackage ([string $pkg = ''], [string $path = ''], [string|null $prefix = null])
 mixed|null call (string $class, string $method, [ $args = array()], [boolean $transient = false])
 void commit ()
 boolean connect ([array $driverOptions = array ()])
 void errorCode ()
 void errorInfo ()
 string escape (string $string)
 void exec ( $query)
 array|string|null fromCache (string|xPDOCriteria $signature, [string $class = ''], [array $options = array()])
 mixed fromJSON (string $src, [boolean $asArray = true])
 array getAggregates (string $className)
 array getAncestry (string $className, [boolean $includeSelf = true])
 void getAttribute ( $attribute)
 object The getCacheManager ([string $class = 'cache.xPDOCacheManager'], [ $options = array('path' => XPDO_CORE_PATH, 'ignorePkg' => true)], string $path, boolean $ignorePkg)
 string getCachePath ()
 array|null getCollection (string $className, [object|array|string $criteria = null], [mixed $cacheFlag = false])
 array getCollectionGraph (string $className, string|array $graph, [mixed $criteria = null], [boolean $cacheFlag = true])
 array getComposites (string $className)
 integer getCount (string $className, [mixed $criteria = null])
 xPDOCriteria getCriteria (string $className, [string $type = null], [boolean|integer $cacheFlag = true])
 string|null getCriteriaType (mixed $criteria)
 boolean getDebug ()
 object|null getDriver ()
 array getFieldMeta (string $className)
 array getFields (string $className)
 array getFKDefinition (string $parentClass, string $alias)
 array getIndexMeta (string $className)
 xPDOIterator getIterator (string $className, [mixed $criteria = null], [bool $cacheFlag = false])
 integer getLogLevel ()
 integer getLogTarget ()
 object|null getManager ()
 float getMicroTime ()
 string getModelVersion (string $className)
 object|null getObject (string $className, [mixed $criteria = null], [mixed $cacheFlag = false])
 object The getObjectGraph (string $className, string|array $graph, [mixed $criteria = null], [boolean|integer $cacheFlag = true])
 callable getObjectLoader (string $className, string $method)
 mixed getOption (string $key, [array $options = null], [mixed $default = null])
 string getPackage (string $className)
 int|null getPDOType (mixed $value)
 mixed getPK (string $className)
 string getPKType (string $className, [ $pk = false])
 string getSelectColumns (string $className, [string $tableAlias = ''], [string $columnPrefix = ''], [array $columns = array ()], [boolean $exclude = false])
 object The getService (string $name, [string $class = ''], [string $path = ''], [array $params = array ()])
 string getTableMeta (string $className)
 string getTableName (string $className, [boolean $includeDb = false])
 array getValidationRules (string $className)
 void lastInsertId ()
 string literal (string $string)
 string|boolean loadClass (string $fqn, [ $path = ''], [ $ignorePkg = false], [ $transient = false])
 void log (integer $level, string $msg, [string $target = ''], [string $def = ''], [string $file = ''], [string $line = ''])
 object|null newObject (string $className, [array $fields = array ()])
 xPDOQuery newQuery (string $class, [mixed $criteria = null], [boolean|integer $cacheFlag = true])
 string parseBindings (string $sql, array $bindings)
 void prepare ( $statement, [ $driver_options = array ()])
 void query ( $query)
 void quote ( $string, [ $parameter_type = PDO::PARAM_STR])
 boolean|integer removeCollection (string $className, mixed $criteria)
 boolean removeObject (string $className, mixed $criteria)
 void rollBack ()
 void setAttribute ( $attribute,  $value)
 void setDebug ([boolean $v = true])
 integer setLogLevel ([integer $level = xPDO::LOG_LEVEL_FATAL])
 mixed setLogTarget ([string $target = 'ECHO'])
 void setOption (string $key, mixed $value)
 void setPackage ([string $pkg = ''], [string $path = ''], [string|null $prefix = null])
 boolean toCache (string|xPDOCriteria $signature, object $object, [integer $lifetime = 0], [array $options = array()])
 string toJSON (array $array)
 string _getLogLevel (integer $level)
 void _loadClass ( $class,  $fqn, [ $included = false], [ $path = ''], [ $transient = false])
 void _log (integer $level, string $msg, [string $target = ''], [string $def = ''], [string $file = ''], [string $line = ''])
Variables
xPDOCacheManager $cacheManager = null (line 180)

Constants

  • var: The cache service provider registered for this xPDO instance.
  • access: public
array $config = null (line 144)

A array of xPDO configuration attributes.

Constants

  • access: public
xPDODriver $driver = null (line 150)

An xPDODriver instance for the connection.

Constants

  • access: public
int $executedQueries = 0 (line 197)

Constants

  • var: The number of direct DB queries executed during a request.
  • access: public
integer $logLevel = xPDO::LOG_LEVEL_FATAL (line 206)

Constants

  • var: The logging level for the XPDO instance.
  • access: protected
string $logTarget = 'ECHO' (line 211)

Constants

  • var: The default logging target for the XPDO instance.
  • access: protected
xPDOManager $manager = null (line 175)

xPDOManager instance, loaded only if needed to manage datasource containers, data structures, etc.

Constants

  • access: public
array $map = array () (line 156)

A map of data source meta data for all loaded classes.

Constants

  • access: public
string $package = '' (line 162)

A default package for specifying classes by name.

Constants

  • access: public
array $packages = array () (line 168)

An array storing packages and package-specific information.

Constants

  • access: public
PDO $pdo = null (line 138)

A PDO instance used by xPDO for database access.

Constants

  • access: public
int $queryTime = 0 (line 201)

Constants

  • var: The amount of request handling time spent with DB queries.
  • access: public
array $services = array () (line 188)

Constants

  • var: An array of supplemental service classes for this xPDO instance.
  • access: public
float $startTime = 0 (line 193)

Constants

  • var: Start time of the request, initialized when the constructor is called.
  • access: public
boolean $_cacheEnabled = false (line 224)

A global cache flag that can be used to enable/disable all xPDO caching.

Constants

  • var: All caching is disabled by default.
  • access: public
boolean $_debug = false (line 218)

Indicates the debug state of this instance.

Constants

  • var: Default is false.
  • access: protected
string $_escapeCharClose = '' (line 236)

Indicates the closing escape character used for a particular database engine.

Constants

  • access: public
string $_escapeCharOpen = '' (line 230)

Indicates the opening escape character used for a particular database engine.

Constants

  • access: public
Methods
static escSplit (line 2109)

Splits a string on a specified character, ignoring escaped content.

Constants

  • return: An array of results from the split operation, or an empty array.
  • access: public
static array escSplit (string $char, string $str, [string $escToken = '`'], [integer $limit = 0])
  • string $char: A character to split the tag content on.
  • string $str: The string to operate on.
  • string $escToken: A character used to surround escaped content; all content within a pair of these tokens will be ignored by the split operation.
  • integer $limit: Limit the number of results. Default is 0 which is no limit. Note that setting the limit to 1 will only return the content up to the first instance of the split character and will discard the remainder of the string.
static parseDSN (line 1689)

Parses a DSN and returns an array of the connection details.

Constants

  • return: An array of connection details from the DSN.
  • todo: Have this method handle all methods of DSN specification as handled by latest native PDO implementation.
  • access: public
static array parseDSN (string $string)
  • string $string: The DSN to parse.
Constructor __construct (line 255)

The xPDO Constructor.

Constants

This method is used to create a new xPDO object with a connection to a specific database container.

  • return: A unique xPDO instance.
  • access: public
xPDO __construct (mixed $dsn, [string $username = ''], [string $password = ''], [array|string $options = array()], [mixed $driverOptions = null])
  • mixed $dsn: A valid DSN connection string.
  • string $username: The database username with proper permissions.
  • string $password: The password for the database user.
  • array|string $options: An array of xPDO options. For compatibility with previous releases, this can also be a single string representing a prefix to be applied to all database container (i. e. table) names, to isolate multiple installations or conflicting table names that might need to coexist in a single database container. It is preferrable to include the table_prefix option in the array for future compatibility.
  • mixed $driverOptions: Driver-specific PDO options.
addDerivativeCriteria (line 890)

Add criteria when requesting a derivative class row automatically.

Constants

This applies class_key filtering for single-table inheritance queries and may provide a convenient location for similar features in the future.

  • access: public
void addDerivativeCriteria (string $className, xPDOCriteria $criteria)
  • string $className: A valid xPDOObject derivative table class.
  • xPDOCriteria $criteria: A valid xPDOCriteria instance.
addPackage (line 389)

Adds a model package and base class path for including classes and/or maps from.

Constants

  • access: public
void addPackage ([string $pkg = ''], [string $path = ''], [string|null $prefix = null])
  • string $pkg: A package name to use when looking up classes/maps in xPDO.
  • string $path: The root path for looking up classes in this package.
  • string|null $prefix: Provide a string to define a package-specific table_prefix.
beginTransaction (line 1921)

Constants

void beginTransaction ()
call (line 558)

Call a static method from a valid package class with arguments.

Constants

Will always search for database-specific class files first.

  • return: The callback method's return value or null if no valid method is found.
  • access: public
mixed|null call (string $class, string $method, [ $args = array()], [boolean $transient = false])
  • string $class: The name of a class to to get the static method from.
  • string $method: The name of the method you want to call.
  • array $args: An array of arguments for the method.
  • boolean $transient: Indicates if the class has dbtype derivatives. Set to true if you want to use on classes not derived from xPDOObject.
commit (line 1931)

Constants

void commit ()
connect (line 318)

Create the PDO connection to a database specified in the configuration.

Constants

  • return: Returns true if the PDO connection was created successfully.
  • access: public
boolean connect ([array $driverOptions = array ()])
  • array $driverOptions: An optional array of driver options to use when creating the connection.
errorCode (line 1957)

Constants

void errorCode ()
errorInfo (line 1967)

Constants

void errorInfo ()
escape (line 1645)

Escapes the provided string using the platform-specific escape character.

Constants

Different database engines escape string literals in SQL using different characters. For example, this is used to escape column names that might match a reserved string for that SQL interpreter. To write database agnostic queries with xPDO, it is highly recommend to escape any database or column names in any native SQL strings used.

  • return: The string escaped with the platform-specific escape characters.
  • access: public
string escape (string $string)
  • string $string: A string to escape using the platform-specific escape characters.
exec (line 1941)

Constants

void exec ( $query)
  • $query
fromCache (line 1721)

Retrieves a result array from the object cache.

Constants

  • return: A PHP array or JSON object representing the result set, or null if no cache representation is found.
  • access: public
array|string|null fromCache (string|xPDOCriteria $signature, [string $class = ''], [array $options = array()])
  • string|xPDOCriteria $signature: A unique string or xPDOCriteria object that represents the query identifying the result set.
  • string $class: An optional classname the result represents.
  • array $options: Various cache options.
fromJSON (line 1899)

Converts a JSON source string into an equivalent PHP representation.

Constants

  • return: The PHP representation of the JSON source.
  • access: public
mixed fromJSON (string $src, [boolean $asArray = true])
  • string $src: A JSON source string.
  • boolean $asArray: Indicates if the result should treat objects as associative arrays; since all JSON associative arrays are objects, the default is true. Set to false to have JSON objects returned as PHP objects.
getAggregates (line 1228)

Gets a collection of aggregate foreign key relationship definitions.

Constants

  • return: An array of aggregate foreign key relationship definitions.
  • access: public
array getAggregates (string $className)
  • string $className: The fully-qualified name of the class.
getAncestry (line 1271)

Retrieves the complete ancestry for a class.

Constants

  • return: An array of string class names representing the class hierarchy, or an empty array if unsuccessful.
  • access: public
array getAncestry (string $className, [boolean $includeSelf = true])
  • string $className: className The name of the class.
  • boolean $includeSelf: includeSelf Determines if the specified class should be included in the resulting array.
getAttribute (line 1977)

Constants

void getAttribute ( $attribute)
  • $attribute
getCacheManager (line 1428)

Gets the xPDOCacheManager instance.

Constants

This class is responsible for handling all types of caching operations for the xPDO core.

  • return: xPDOCacheManager for this xPDO instance.
  • access: public
  • uses: xPDOCacheManager
object The getCacheManager ([string $class = 'cache.xPDOCacheManager'], [ $options = array('path' => XPDO_CORE_PATH, 'ignorePkg' => true)], string $path, boolean $ignorePkg)
  • string $class: Optional name of a derivative xPDOCacheManager class.
  • string $path: Optional root path for looking up the $class.
  • boolean $ignorePkg: If false and you do not specify a path, you can look up custom xPDOCacheManager derivatives in declared packages.
  • $options
getCachePath (line 1407)

Gets the absolute path to the cache directory.

Constants

  • return: The full cache directory path.
  • access: public
string getCachePath ()
getCollection (line 679)

Retrieves a collection of xPDOObjects by the specified xPDOCriteria.

Constants

array|null getCollection (string $className, [object|array|string $criteria = null], [mixed $cacheFlag = false])
  • 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.
getCollectionGraph (line 838)

Retrieves a collection of xPDOObject instances with related objects.

Constants

  • return: An array of instances matching the criteria with related objects from the graph hydrated. An empty array is returned when no matches are found.
  • access: public
  • usedby: xPDO::getObjectGraph()
  • uses: xPDOQuery::bindGraph()
array getCollectionGraph (string $className, string|array $graph, [mixed $criteria = null], [boolean $cacheFlag = true])
  • 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('relationAlias'=>array('subRelationAlias'=>array())) or {"relationAlias":{"subRelationAlias":{}}}. Note that the empty arrays are necessary in order for the relation to be recognized.
  • mixed $criteria: A valid xPDOCriteria instance or condition string.
  • boolean $cacheFlag: Indicates if the result set should be cached.
getComposites (line 1248)

Gets a collection of composite foreign key relationship definitions.

Constants

  • return: An array of composite foreign key relationship definitions.
  • access: public
array getComposites (string $className)
  • string $className: The fully-qualified name of the class.
getCount (line 773)

Retrieves a count of xPDOObjects by the specified xPDOCriteria.

Constants

  • return: The number of instances found by the criteria.
  • access: public
integer getCount (string $className, [mixed $criteria = null])
  • string $className: Class of xPDOObject to count instances of.
  • mixed $criteria: Any valid xPDOCriteria object or expression.
getCriteria (line 859)

Convert any valid criteria into an xPDOQuery instance.

Constants

  • return: A criteria object or null if not found.
  • todo: Define callback functions as an alternative to retreiving criteria sql and/or bindings from the metadata.
  • todo: Get criteria pre-defined in an xPDOObject class metadata definition by name.
  • access: public
xPDOCriteria getCriteria (string $className, [string $type = null], [boolean|integer $cacheFlag = true])
  • 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).
  • boolean|integer $cacheFlag: Indicates if the result is cached and optionally for how many seconds.
getCriteriaType (line 869)

Validate and return the type of a specified criteria variable.

Constants

  • return: The type of valid criteria passed, or null if the criteria is not valid.
  • access: public
string|null getCriteriaType (mixed $criteria)
  • mixed $criteria: An xPDOCriteria instance or any valid criteria variable.
getDebug (line 1444)

Returns the debug state for the XPDO connection.

Constants

  • return: The current debug state for the connection, true for on, false for off.
  • access: public
boolean getDebug ()
getDebugBacktrace (line 1592)

Returns an abbreviated backtrace of debugging information.

Constants

This function returns just the fields returned via xPDOObject::toArray() on xPDOObject instances, and simply the classname for other objects, to reduce the amount of unnecessary information returned.

  • return: The abbreviated backtrace.
  • access: public
array getDebugBacktrace ()
getDriver (line 1388)

Gets the driver class for this xPDO connection.

Constants

The driver class provides baseline data and operations for a specific database driver.

  • return: A driver instance for the xPDO connection, or null if a driver class can not be instantiated.
  • access: public
  • uses: xPDODriver
object|null getDriver ()
getFieldMeta (line 1079)

Gets a list of field (or column) definitions for an object by class name.

Constants

These definitions are used by the objects themselves to build their own meta data based on class inheritence.

  • 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.
  • access: public
array getFieldMeta (string $className)
  • string $className: The name of the class to lookup fields meta data for.
getFields (line 1053)

Gets a list of fields (or columns) for an object by class name.

Constants

This includes default values for each field and is used by the objects themselves to build their initial attributes based on class inheritence.

  • return: An array featuring field names as the array keys, and default field values as the array values; empty array is returned if unsuccessful.
  • access: public
array getFields (string $className)
  • string $className: The name of the class to lookup fields for.
getFKDefinition (line 1315)

Gets an aggregate or composite relation definition from a class.

Constants

  • return: The aggregate or composite definition details in an array or null if no definition is found.
array getFKDefinition (string $parentClass, string $alias)
  • string $parentClass: The class from which the relation is defined.
  • string $alias: The alias identifying the related class.
getIndexMeta (line 1125)

Get indices defined for a table class.

Constants

  • return: An array of indices and their details for the specified class.
  • access: public
array getIndexMeta (string $className)
  • string $className: The name of the class to lookup indices for.
getIterator (line 694)

Retreives an iterable representation of a collection of xPDOObjects.

Constants

  • return: An iterable representation of a collection.
  • access: public
xPDOIterator getIterator (string $className, [mixed $criteria = null], [bool $cacheFlag = false])
  • string $className: Name of the class to search for instances of.
  • mixed $criteria: An xPDOCriteria object or representation.
  • bool $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.
getLogLevel (line 1472)

Constants

  • return: The current log level.
  • access: public
integer getLogLevel ()
getLogTarget (line 1503)

Constants

  • return: The current log level.
  • access: public
integer getLogTarget ()
getManager (line 1365)

Gets the manager class for this xPDO connection.

Constants

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.

  • return: A manager instance for the xPDO connection, or null if a manager class can not be instantiated.
  • access: public
  • uses: xPDOManager
object|null getManager ()
getMicroTime (line 2068)

Convert current microtime() result into seconds.

Constants

  • access: public
float getMicroTime ()
getModelVersion (line 1344)

Gets the version string of the schema the specified class was generated from.

Constants

  • return: The version string for the schema model the class was generated from.
  • access: public
string getModelVersion (string $className)
  • string $className: The name of the class to get the model version from.
getObject (line 658)

Retrieves a single object instance by the specified criteria.

Constants

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.

  • return: An instance of the class, or null if it could not be instantiated.
  • access: public
  • uses: xPDOObject::load()
object|null getObject (string $className, [mixed $criteria = null], [mixed $cacheFlag = false])
  • 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.
getObjectGraph (line 812)

Retrieves an xPDOObject instance with specified related objects.

Constants

  • return: object instance with related objects from the graph hydrated, or null if no instance can be located by the criteria.
  • access: public
  • uses: xPDO::getCollectionGraph()
object The getObjectGraph (string $className, string|array $graph, [mixed $criteria = null], [boolean|integer $cacheFlag = true])
  • 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('relationAlias'=>array('subRelationAlias'=>array())) or {"relationAlias":{"subRelationAlias":{}}}. Note that the empty arrays are necessary in order for the relation to be recognized.
  • mixed $criteria: A valid xPDOCriteria instance or expression.
  • boolean|integer $cacheFlag: Indicates if the result set should be cached, and optionally for how many seconds.
getObjectLoader (line 620)

Finds the class responsible for loading instances of the specified class.

Constants

  • return: A callable loader function.
  • deprecated: Use call() instead.
  • access: public
callable getObjectLoader (string $className, string $method)
  • string $className: The name of the class to find a loader for.
  • string $method: Indicates the specific loader method to use, loadCollection or loadObject (or other public static methods).
getOption (line 516)

Get an xPDO configuration option value by key.

Constants

  • return: The configuration option value.
  • access: public
mixed getOption (string $key, [array $options = null], [mixed $default = null])
  • string $key: The option key.
  • array $options: A set of options to override those from xPDO.
  • mixed $default: An optional default value to return if no value is found.
getPackage (line 918)

Gets the package name from a specified class name.

Constants

  • return: The package the class belongs to.
  • access: public
string getPackage (string $className)
  • string $className: The name of the class to lookup the package for.
getPDOType (line 2210)

Get the appropriate PDO::PARAM_ type constant from a PHP value.

Constants

  • access: public
int|null getPDOType (mixed $value)
  • mixed $value: Any PHP scalar or null value
getPK (line 1151)

Gets the primary key field(s) for a class.

Constants

  • 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.
  • access: public
mixed getPK (string $className)
  • string $className: The name of the class to lookup the primary key for.
getPKType (line 1194)

Gets the type of primary key field for a class.

Constants

  • 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.
  • todo: Refactor method to return array of types rather than compound!
  • access: public
string getPKType (string $className, [ $pk = false])
  • string $className: className The name of the class to lookup the primary key type for.
  • $pk
getSelectColumns (line 1303)

Gets select columns from a specific class for building a query.

Constants

string getSelectColumns (string $className, [string $tableAlias = ''], [string $columnPrefix = ''], [array $columns = array ()], [boolean $exclude = false])
  • 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.
getService (line 945)

Load and return a named service class instance.

Constants

  • return: service class instance or null if it could not be loaded.
  • access: public
object The getService (string $name, [string $class = ''], [string $path = ''], [array $params = array ()])
  • string $name: The variable name of the instance.
  • string $class: The service class name.
  • string $path: An optional root path to search for the class.
  • array $params: An array of optional params to pass to the service class constructor.
getTableMeta (line 1023)

Gets the actual run-time table metadata from a specified class name.

Constants

  • return: The table meta data for the class, or null if unsuccessful.
  • access: public
string getTableMeta (string $className)
  • string $className: The name of the class to lookup a table name for.
getTableName (line 982)

Gets the actual run-time table name from a specified class name.

Constants

  • return: The table name for the class, or null if unsuccessful.
  • access: public
string getTableName (string $className, [boolean $includeDb = false])
  • string $className: The name of the class to lookup a table name for.
  • boolean $includeDb: Qualify the table name with the database name.
getValidationRules (line 1102)

Gets a set of validation rules defined for an object by class name.

Constants

  • return: An array featuring field names as the array keys, and arrays of validation rule information as the array values; empty array is returned if unsuccessful.
  • access: public
array getValidationRules (string $className)
  • string $className: The name of the class to lookup validation rules for.
lastInsertId (line 1987)

Constants

void lastInsertId ()
literal (line 1656)

Use to insert a literal string into a SQL query without escaping or quoting.

Constants

  • return: The string with any escape or quote characters trimmed.
  • access: public
string literal (string $string)
  • string $string: A string to return as a literanl, unescaped and unquoted.
loadClass (line 424)

Load a class by fully qualified name.

Constants

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

  • return: The actual classname if successful, or false if not.
  • access: public
string|boolean loadClass (string $fqn, [ $path = ''], [ $ignorePkg = false], [ $transient = false])
  • string $fqn: The fully-qualified name of the class to load.
  • $path
  • $ignorePkg
  • $transient
log (line 1519)

Log a message with details about where and when an event occurs.

Constants

  • access: public
void log (integer $level, string $msg, [string $target = ''], [string $def = ''], [string $file = ''], [string $line = ''])
  • integer $level: The level of the logged message.
  • string $msg: The message to log.
  • string $target: The logging target.
  • string $def: The name of a defining structure (such as a class) to help identify the message source.
  • string $file: A filename in which the log event occured.
  • string $line: A line number to help locate the source of the event within the indicated file.
newObject (line 598)

Creates a new instance of a specified class.

Constants

All new objects created with this method are transient until xPDOObject::save() is called the first time and is reflected by the xPDOObject::$_new property.

  • return: A new instance of the specified class, or null if a new object could not be instantiated.
  • access: public
object|null newObject (string $className, [array $fields = array ()])
  • 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.
newQuery (line 2082)

Creates an new xPDOQuery for a specified xPDOObject class.

Constants

  • return: The resulting xPDOQuery instance or false if unsuccessful.
  • access: public
xPDOQuery newQuery (string $class, [mixed $criteria = null], [boolean|integer $cacheFlag = true])
  • string $class: The class to create the xPDOQuery for.
  • mixed $criteria: Any valid xPDO criteria expression.
  • boolean|integer $cacheFlag: Indicates if the result should be cached and optionally for how many seconds (if passed an integer greater than 0).
parseBindings (line 2156)

Parses parameter bindings in SQL prepared statements.

Constants

  • return: The SQL with the binding placeholders replaced.
  • access: public
string parseBindings (string $sql, array $bindings)
  • string $sql: A SQL prepared statement to parse bindings in.
  • array $bindings: An array of parameter bindings to use for the replacements.
prepare (line 1997)

Constants

void prepare ( $statement, [ $driver_options = array ()])
  • $statement
  • $driver_options
query (line 2007)

Constants

void query ( $query)
  • $query
quote (line 2023)

Constants

void quote ( $string, [ $parameter_type = PDO::PARAM_STR])
  • $string
  • $parameter_type
removeCollection (line 741)

Remove a collection of instances by the supplied className and criteria.

Constants

  • return: False if the remove encounters an error, otherwise an integer value representing the number of rows that were removed.
  • access: public
boolean|integer removeCollection (string $className, mixed $criteria)
  • string $className: The name of the class to remove a collection of.
  • mixed $criteria: Valid xPDO criteria for selecting a collection.
removeObject (line 705)

Remove an instance of the specified className by a supplied criteria.

Constants

  • return: True if the instance is successfully removed.
  • access: public
boolean removeObject (string $className, mixed $criteria)
  • string $className: The name of the class to remove an instance of.
  • mixed $criteria: Valid xPDO criteria for selecting an instance.
rollBack (line 2045)

Constants

void rollBack ()
setAttribute (line 2055)

Constants

void setAttribute ( $attribute,  $value)
  • $attribute
  • $value
setDebug (line 1453)

Sets the debug state for the XPDO connection.

Constants

  • access: public
void setDebug ([boolean $v = true])
  • boolean $v: The debug status, true for on, false for off.
setLogLevel (line 1463)

Sets the logging level state for the XPDO instance.

Constants

  • return: The previous log level.
  • access: public
integer setLogLevel ([integer $level = xPDO::LOG_LEVEL_FATAL])
  • integer $level: The logging level to switch to.
setLogTarget (line 1494)

Sets the log target for xPDO::_log() calls.

Constants

Valid target values include:

  • 'ECHO': Returns output to the STDOUT.
  • 'HTML': Returns output to the STDOUT with HTML formatting.
  • 'FILE': Sends output to a log file.
  • An array with at least one element with key 'target' matching one of the valid log targets listed above. For 'target' => 'FILE' you can specify a second element with key 'options' with another associative array with one or both of the elements 'filename' and 'filepath'

  • return: The previous log target.
  • access: public
mixed setLogTarget ([string $target = 'ECHO'])
  • string $target: An identifier indicating the target of the logging.
setOption (line 542)

Sets an xPDO configuration option value.

Constants

  • access: public
void setOption (string $key, mixed $value)
  • string $key: The option key.
  • mixed $value: A value to set for the given option key.
setPackage (line 370)

Sets a specific model package to use when looking up classes.

Constants

This package is of the form package.subpackage.subsubpackage and will be added to the beginning of every xPDOObject class that is referenced in xPDO methods such as xPDO::loadClass(), xPDO::getObject(), xPDO::getCollection(), xPDOObject::getOne(), xPDOObject::addOne(), etc.

  • access: public
void setPackage ([string $pkg = ''], [string $path = ''], [string|null $prefix = null])
  • 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.
  • string|null $prefix: Provide a string to define a package-specific table_prefix.
toCache (line 1782)

Places a result set in the object cache.

Constants

  • return: Indicates if the object was successfully cached.
  • access: public
boolean toCache (string|xPDOCriteria $signature, object $object, [integer $lifetime = 0], [array $options = array()])
  • string|xPDOCriteria $signature: A unique string or xPDOCriteria object representing the object.
  • object $object: An object to place a representation of in the cache.
  • integer $lifetime: An optional number of seconds the cached result will remain valid, with 0 meaning it will remain valid until replaced or removed.
  • array $options: Various cache options.
toJSON (line 1875)

Converts a PHP array into a JSON encoded string.

Constants

  • return: The JSON representation of the source array.
  • access: public
string toJSON (array $array)
  • array $array: The PHP array to convert.
_getLogLevel (line 1614)

Gets a logging level as a string representation.

Constants

  • return: The string representation of a valid logging level.
  • access: protected
string _getLogLevel (integer $level)
  • integer $level: The logging level to retrieve a string for.
_loadClass (line 484)

Constants

  • access: protected
void _loadClass ( $class,  $fqn, [ $included = false], [ $path = ''], [ $transient = false])
  • $class
  • $fqn
  • $included
  • $path
  • $transient
_log (line 1535)

Log a message as appropriate for the level and target.

Constants

  • access: protected
void _log (integer $level, string $msg, [string $target = ''], [string $def = ''], [string $file = ''], [string $line = ''])
  • integer $level: The level of the logged message.
  • string $msg: The message to log.
  • string $target: The logging target.
  • string $def: The name of a defining structure (such as a class) to help identify the log event source.
  • string $file: A filename in which the log event occured.
  • string $line: A line number to help locate the source of the event within the indicated file.
Class Constants
LOG_LEVEL_DEBUG = 4 (line 129)

Constants

LOG_LEVEL_ERROR = 1 (line 126)

Constants

LOG_LEVEL_FATAL = 0 (line 125)

Constants

LOG_LEVEL_INFO = 3 (line 128)

Constants

LOG_LEVEL_WARN = 2 (line 127)

Constants

OPT_BASE_CLASSES = 'base_classes' (line 97)

Constants

OPT_BASE_PACKAGES = 'base_packages' (line 98)

Constants

OPT_CACHE_COMPRESS = 'cache_compress' (line 99)

Constants

OPT_CACHE_DB = 'cache_db' (line 100)

Constants

OPT_CACHE_DB_COLLECTIONS = 'cache_db_collections' (line 101)

Constants

OPT_CACHE_DB_EXPIRES = 'cache_db_expires' (line 103)

Constants

OPT_CACHE_DB_HANDLER = 'cache_db_handler' (line 104)

Constants

OPT_CACHE_DB_OBJECTS_BY_PK = 'cache_db_objects_by_pk' (line 102)

Constants

OPT_CACHE_EXPIRES = 'cache_expires' (line 105)

Constants

OPT_CACHE_HANDLER = 'cache_handler' (line 106)

Constants

OPT_CACHE_KEY = 'cache_key' (line 107)

Constants

OPT_CACHE_PATH = 'cache_path' (line 108)

Constants

OPT_CALLBACK_ON_REMOVE = 'callback_on_remove' (line 109)

Constants

OPT_CALLBACK_ON_SAVE = 'callback_on_save' (line 110)

Constants

OPT_HYDRATE_ADHOC_FIELDS = 'hydrate_adhoc_fields' (line 112)

Constants

OPT_HYDRATE_FIELDS = 'hydrate_fields' (line 111)

Constants

OPT_HYDRATE_RELATED_OBJECTS = 'hydrate_related_objects' (line 113)

Constants

OPT_LOADER_CLASSES = 'loader_classes' (line 118)

Constants

OPT_ON_SET_STRIPSLASHES = 'on_set_stripslashes' (line 119)

Constants

OPT_SETUP = 'setup' (line 120)

Constants

OPT_TABLE_PREFIX = 'table_prefix' (line 121)

Constants

OPT_VALIDATE_ON_SAVE = 'validate_on_save' (line 122)

Constants

OPT_VALIDATOR_CLASS = 'validator_class' (line 123)

Constants

SCHEMA_VERSION = '1.1' (line 131)

Constants

Documentation generated on Mon, 27 Dec 2010 11:08:26 -0700 by phpDocumentor 1.4.3