src/xPDO/xPDO.php
public static function getInstance($id = null, $config = null, $forceNew = false) {
        $instances =& self::$instances;
        if (is_null($id)) {
            if (!is_null($config) || $forceNew || empty($instances)) {
                $id = uniqid(__CLASS__);
            } else {
                $id = key($instances);
            }
        }
        if ($forceNew || !array_key_exists($id, $instances) || !($instances[$id] instanceof xPDO)) {
            $instances[$id] = new xPDO(null, null, null, $config);
        } elseif ($instances[$id] instanceof xPDO && is_array($config)) {
            $instances[$id]->config = array_merge($instances[$id]->config, $config);
        }
        if (!($instances[$id] instanceof xPDO)) {
            throw new xPDOException("Error getting " . __CLASS__ . " instance, id = {$id}");
        }
        return $instances[$id];
    }
public static function getInstance($id = null, $config = null, $forceNew = false) {
        $instances =& self::$instances;
        if (is_null($id)) {
            if (!is_null($config) || $forceNew || empty($instances)) {
                $id = uniqid(__CLASS__);
            } else {
                $id = key($instances);
            }
        }
        if ($forceNew || !array_key_exists($id, $instances) || !($instances[$id] instanceof xPDO)) {
            $instances[$id] = new xPDO(null, null, null, $config);
        } elseif ($instances[$id] instanceof xPDO && is_array($config)) {
            $instances[$id]->config = array_merge($instances[$id]->config, $config);
        }
        if (!($instances[$id] instanceof xPDO)) {
            throw new xPDOException("Error getting " . __CLASS__ . " instance, id = {$id}");
        }
        return $instances[$id];
    }
public static function getInstance ( $ id = null , $ config = null , $ forceNew = false ) { $ instances = & self :: $ instances ; if ( is_null ( $ id ) ) { if ( ! is_null ( $ config ) || $ forceNew || empty ( $ instances ) ) { $ id = uniqid ( __CLASS__ ) ; } else { $ id = key ( $ instances ) ; } } if ( $ forceNew || ! array_key_exists ( $ id , $ instances ) || ! ( $ instances [ $ id ] instanceof xPDO ) ) { $ instances [ $ id ] = new xPDO ( null , null , null , $ config ) ; } elseif ( $ instances [ $ id ] instanceof xPDO && is_array ( $ config ) ) { $ instances [ $ id ] -> config = array_merge ( $ instances [ $ id ] -> config , $ config ) ; } if ( ! ( $ instances [ $ id ] instanceof xPDO ) ) { throw new xPDOException ( "Error getting " . __CLASS__ . " instance, id = {$id}" ) ; } return $ instances [ $ id ] ; }
Create, retrieve, or update specific xPDO instances.

@param string|int|null $id An optional identifier for the instance. If not set
a uniqid will be generated and used as the key for the instance.
@param array|ContainerInterface|null $config An optional container or array of config data
for the instance.
@param bool $forceNew If true a new instance will be created even if an instance
with the provided $id already exists in xPDO::$instances.

@throws xPDOException If a valid instance is not retrieved.
@return xPDO An instance of xPDO.
Create retrieve or update specific xPDO instances .