public static function getTable($componentName)
{
- return IPF_ORM_Manager::getInstance()->getConnectionForComponent($componentName)->getTable($componentName);
+ return IPF_ORM_Manager::connection()->getTable($componentName);
}
public static function generateModelsFromYaml($directory, $extraAllwedReferences=array())
public function unserialize($serialized)
{
- $manager = IPF_ORM_Manager::getInstance();
- $connection = $manager->getCurrentConnection();
+ $connection = IPF_ORM_Manager::connection();
$array = unserialize($serialized);
{
protected $dbh;
protected $tables = array();
- protected $_name;
+ protected $_name = 0;
protected $driverName;
- protected $isConnected = false;
protected $pendingAttributes = array();
private $modules = array('transaction' => false,
public $dbListeners = array();
- public function __construct(IPF_ORM_Manager $manager, $adapter, $user = null, $pass = null)
+ public function __construct(IPF_ORM_Manager $manager, $pdo, $user = null, $pass = null)
{
- if (is_object($adapter)) {
- if (!($adapter instanceof PDO)) {
- throw new IPF_ORM_Exception('First argument should be an instance of PDO');
- }
- $this->dbh = $adapter;
- $this->isConnected = true;
- } else if (is_array($adapter)) {
- $this->options['dsn'] = $adapter['dsn'];
- $this->options['username'] = $adapter['username'];
- $this->options['password'] = $adapter['password'];
-
- $this->options['other'] = array();
- if (isset($adapter['options'])) {
- if (in_array('persistent', $adapter['options']))
- $this->options['other'][PDO::ATTR_PERSISTENT] = true;
- }
- }
+ $this->dbh = $pdo;
$this->setParent($manager);
$this->dbListeners = $manager->dbListeners;
return $this->attributes[$attribute];
}
- if ($this->isConnected) {
- try {
- return $this->dbh->getAttribute($attribute);
- } catch (Exception $e) {
- throw new IPF_ORM_Exception('Attribute ' . $attribute . ' not found.');
- }
- } else {
- if ( ! isset($this->pendingAttributes[$attribute])) {
- $this->connect();
- $this->getAttribute($attribute);
- }
-
- return $this->pendingAttributes[$attribute];
+ try {
+ return $this->dbh->getAttribute($attribute);
+ } catch (Exception $e) {
+ throw new IPF_ORM_Exception('Attribute ' . $attribute . ' not found.');
}
}
if ($attribute >= 100) {
parent::setAttribute($attribute, $value);
} else {
- if ($this->isConnected) {
- $this->dbh->setAttribute($attribute, $value);
- } else {
- $this->pendingAttributes[$attribute] = $value;
- }
+ $this->dbh->setAttribute($attribute, $value);
}
return $this;
return $this->_name;
}
- public function setName($name)
- {
- $this->_name = $name;
- }
-
public function getDriverName()
{
return $this->driverName;
public function getDbh()
{
- $this->connect();
return $this->dbh;
}
- public function connect()
- {
- if ($this->isConnected)
- return false;
-
- $event = new IPF_ORM_Event($this, IPF_ORM_Event::CONN_CONNECT);
-
- $this->notifyDBListeners('preConnect', $event);
-
- $e = explode(':', $this->options['dsn']);
- $found = false;
-
- if (extension_loaded('pdo')) {
- if (in_array($e[0], PDO::getAvailableDrivers())) {
- try {
- $this->dbh = new PDO($this->options['dsn'], $this->options['username'],
- (!$this->options['password'] ? '':$this->options['password']), $this->options['other']);
-
- $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch (PDOException $e) {
- throw new IPF_ORM_Exception('PDO Connection Error: ' . $e->getMessage());
- }
- $found = true;
- }
- }
-
- if ( !$found) {
- throw new IPF_Exception_Panic("Couldn't locate driver named " . $e[0]);
- }
-
- // attach the pending attributes to adapter
- foreach($this->pendingAttributes as $attr => $value) {
- $this->dbh->setAttribute($attr, $value);
- }
-
- $this->isConnected = true;
-
- $this->onConnect();
-
- $this->notifyDBListeners('postConnect', $event);
- return true;
- }
-
- protected function onConnect()
- {
- }
-
public function incrementQueryCount()
{
$this->_count++;
public function prepare($statement)
{
- $this->connect();
-
try {
$event = new IPF_ORM_Event($this, IPF_ORM_Event::CONN_PREPARE, $statement);
public function execute($query, array $params = array())
{
- $this->connect();
-
try {
if ( ! empty($params)) {
$stmt = $this->prepare($query);
public function exec($query, array $params = array())
{
- $this->connect();
-
try {
if ( ! empty($params)) {
$stmt = $this->prepare($query);
$this->exported = array();
}
- public function close()
- {
- $event = new IPF_ORM_Event($this, IPF_ORM_Event::CONN_CLOSE);
-
- $this->notifyDBListeners('preClose', $event);
-
- $this->clear();
-
- unset($this->dbh);
- $this->isConnected = false;
-
- $this->notifyDBListeners('postClose', $event);
- }
-
public function getTransactionLevel()
{
return $this->transaction->getTransactionLevel();
public function errorCode()
{
- $this->connect();
-
return $this->dbh->errorCode();
}
public function errorInfo()
{
- $this->connect();
-
return $this->dbh->errorInfo();
}
$this->transaction->rollback($savepoint);
}
- public function createDatabase()
- {
- if ( ! $dsn = $this->getOption('dsn')) {
- throw new IPF_ORM_Exception('You must create your IPF_ORM_Connection by using a valid IPF style dsn in order to use the create/drop database functionality');
- }
-
- // Parse pdo dsn so we are aware of the connection information parts
- $info = $this->getManager()->parsePdoDsn($dsn);
-
- // Get the temporary connection to issue the drop database command
- $tmpConnection = $this->getTmpConnection($info);
-
- try {
- // Issue create database command
- $tmpConnection->export->createDatabase($info['dbname']);
- } catch (Exception $e) {}
-
- // Close the temporary connection used to issue the drop database command
- $this->getManager()->closeConnection($tmpConnection);
-
- // Re-create IPF or PDO style dsn
- if ($info['unix_socket']) {
- $dsn = array($info['scheme'] . ':unix_socket=' . $info['unix_socket'] . ';dbname=' . $info['dbname'], $this->getOption('username'), $this->getOption('password'));
- } else {
- $dsn = $info['scheme'] . '://' . $this->getOption('username') . ':' . $this->getOption('password') . '@' . $info['host'] . '/' . $info['dbname'];
- }
-
- // Re-open connection with the newly created database
- $this->getManager()->openConnection($dsn, $this->getName(), true);
-
- if (isset($e)) {
- return $e;
- } else {
- return 'Successfully created database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"';
- }
- }
-
- public function dropDatabase()
- {
- if ( ! $dsn = $this->getOption('dsn')) {
- throw new IPF_ORM_Exception('You must create your IPF_ORM_Connection by using a valid IPF style dsn in order to use the create/drop database functionality');
- }
-
- // Parse pdo dsn so we are aware of the connection information parts
- $info = $this->getManager()->parsePdoDsn($dsn);
-
- // Get the temporary connection to issue the drop database command
- $tmpConnection = $this->getTmpConnection($info);
-
- try {
- // Issue drop database command
- $tmpConnection->export->dropDatabase($info['dbname']);
- } catch (Exception $e) {}
-
- // Close the temporary connection used to issue the drop database command
- $this->getManager()->closeConnection($tmpConnection);
-
- // Re-create IPF or PDO style dsn
- if ($info['unix_socket']) {
- $dsn = array($info['scheme'] . ':unix_socket=' . $info['unix_socket'] . ';dbname=' . $info['dbname'], $this->getOption('username'), $this->getOption('password'));
- } else {
- $dsn = $info['scheme'] . '://' . $this->getOption('username') . ':' . $this->getOption('password') . '@' . $info['host'] . '/' . $info['dbname'];
- }
-
- // Re-open connection with the newly created database
- $this->getManager()->openConnection($dsn, $this->getName(), true);
-
- if (isset($e)) {
- return $e;
- } else {
- return 'Successfully dropped database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"';
- }
- }
-
- public function getTmpConnection($info)
- {
- if ($info['unix_socket']) {
- $pdoDsn = $info['scheme'] . ':unix_socket=' . $info['unix_socket'];
- } else {
- $pdoDsn = $info['scheme'] . ':host=' . $info['host'];
- }
-
- if (isset($this->export->tmpConnectionDatabase) && $this->export->tmpConnectionDatabase) {
- $pdoDsn .= ';dbname=' . $this->export->tmpConnectionDatabase;
- }
-
- $username = $this->getOption('username');
- $password = $this->getOption('password');
-
- return $this->getManager()->openConnection(new PDO($pdoDsn, $username, $password), 'ipf_tmp_connection', false);
- }
-
public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false)
{
return $query;
public function __construct($conn = null)
{
if ( ! ($conn instanceof IPF_ORM_Connection)) {
- $conn = IPF_ORM_Manager::getInstance()->getCurrentConnection();
+ $conn = IPF_ORM_Manager::connection();
}
$this->conn = $conn;
{
return $this->moduleName;
}
-}
\ No newline at end of file
+}
parent::__construct($manager, $adapter);
}
- protected function onConnect()
- {
- $this->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
- $this->exec('SET NAMES \'utf8\'');
- }
-
public function quoteIdentifier($str)
{
$quote = $this->identifier_quoting;
return $name . '_idx';
}
- public function dropDatabase($database)
- {
- $this->conn->execute($this->dropDatabaseSql($database));
- }
-
- public function dropDatabaseSql($database)
- {
- throw new IPF_ORM_Exception('Drop database not supported by this driver.');
- }
-
public function dropTableSql($table)
{
return 'DROP TABLE ' . $this->conn->quoteIdentifier($table);
return $this->dropConstraint($table, $name);
}
- public function createDatabase($database)
- {
- $this->conn->execute($this->createDatabaseSql($database));
- }
-
- public function createDatabaseSql($database)
- {
- throw new IPF_ORM_Exception('Create database not supported by this driver.');
- }
-
public function createConstraint($table, $name, $definition)
{
$sql = $this->createConstraintSql($table, $name, $definition);
{
$connections = array();
foreach ($classes as $class) {
- $connection = IPF_ORM_Manager::getInstance()->getConnectionForComponent($class);
+ $connection = IPF_ORM_Manager::connection();
$connectionName = $connection->getName();
if ( ! isset($connections[$connectionName])) {
$queries = $this->exportSortedClassesSql($classes);
foreach ($queries as $connectionName => $sql) {
- $connection = IPF_ORM_Manager::getInstance()->getConnection($connectionName);
+ $connection = IPF_ORM_Manager::connection();
$connection->beginTransaction();
class IPF_ORM_Export_Mysql extends IPF_ORM_Export
{
- public function createDatabaseSql($name)
- {
- return 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name);
- }
-
- public function dropDatabaseSql($name)
- {
- return 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
- }
-
public function createTableSql($name, array $fields, array $options = array())
{
if ( ! $name)
'',
);
- if (isset($definition['connection']) && $definition['connection']) {
- $code[] = '// Connection Component Binding';
- $code[] = "IPF_ORM_Manager::getInstance()->bindComponent('" . $definition['connectionClassName'] . "', '" . $definition['connection'] . "');";
- $code[] = '';
- }
-
$code[] = 'abstract class '.$this->_baseClassPrefix.$definition['className'].' extends IPF_ORM_Record';
$code[] = '{';
$code[] = $this->buildTableDefinition($definition);
<?php
-class IPF_ORM_Manager extends IPF_ORM_Configurable implements Countable, IteratorAggregate
+class IPF_ORM_Manager extends IPF_ORM_Configurable
{
- protected $_connections = array();
- protected $_bound = array();
- protected $_index = 0;
- protected $_currIndex = 0;
+ protected $_connection = null;
protected $_queryRegistry;
public $dbListeners = array();
return IPF_ORM_Manager::getInstance()->getCurrentConnection();
}
- public function openConnection($adapter, $name = null, $setCurrent = true)
- {
- if (is_object($adapter)) {
- if (!($adapter instanceof PDO))
- throw new IPF_ORM_Exception("First argument should be an instance of PDO");
- $driverName = $adapter->getAttribute(PDO::ATTR_DRIVER_NAME);
- } else {
- $adapter = $this->connectionParameters($adapter);
- $driverName = $adapter['scheme'];
- }
-
- if ($name !== null) {
- $name = (string) $name;
- if (isset($this->_connections[$name])) {
- if ($setCurrent) {
- $this->_currIndex = $name;
- }
- return $this->_connections[$name];
- }
- } else {
- $name = $this->_index;
- $this->_index++;
- }
-
- $drivers = array('mysql' => 'IPF_ORM_Connection_Mysql',
- //'sqlite' => 'IPF_ORM_Connection_Sqlite',
- //'pgsql' => 'IPF_ORM_Connection_Pgsql',
- //'oci' => 'IPF_ORM_Connection_Oracle',
- //'oci8' => 'IPF_ORM_Connection_Oracle',
- //'oracle' => 'IPF_ORM_Connection_Oracle',
- //'mssql' => 'IPF_ORM_Connection_Mssql',
- //'dblib' => 'IPF_ORM_Connection_Mssql',
- //'firebird' => 'IPF_ORM_Connection_Firebird',
- //'informix' => 'IPF_ORM_Connection_Informix',
- //'mock' => 'IPF_ORM_Connection_Mock'
- );
-
- if ( ! isset($drivers[$driverName])) {
- throw new IPF_ORM_Exception('Unknown driver ' . $driverName);
- }
-
- $className = $drivers[$driverName];
- $conn = new $className($this, $adapter);
- $conn->setName($name);
-
- $this->_connections[$name] = $conn;
-
- if ($setCurrent) {
- $this->_currIndex = $name;
- }
- return $this->_connections[$name];
- }
-
- public function connectionParameters($adapter)
- {
- if (is_array($adapter)) {
- if (!count($adapter))
- throw new IPF_ORM_Exception('Empty data source name given.');
-
- if (array_key_exists('database', $adapter)) {
- $adapter['dsn'] = $this->makeDsnForPDO($adapter['driver'], $adapter['host'], @$adapter['port'], $adapter['database']);
- $adapter['scheme'] = $adapter['driver'];
- return $adapter;
- } else {
- $dsn = urldecode($adapter[0]);
- $result = $this->parseDsn($dsn);
- $result['username'] = (isset($adapter[1])) ? urldecode($adapter[1]) : null;
- $result['password'] = (isset($adapter[2])) ? urldecode($adapter[2]) : null;
- return $result;
- }
- } else {
- $result = $this->parseDsn($adapter);
- $result['username'] = $result['user'];
- $result['password'] = $result['pass'];
- return $result;
- }
- }
-
- public function parsePdoDsn($dsn)
- {
- $parts = array();
-
- $names = array('dsn', 'scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment', 'unix_socket');
-
- foreach ($names as $name) {
- if ( ! isset($parts[$name])) {
- $parts[$name] = null;
- }
- }
-
- $e = explode(':', $dsn);
- $parts['scheme'] = $e[0];
- $parts['dsn'] = $dsn;
-
- $e = explode(';', $e[1]);
- foreach ($e as $string) {
- if ($string) {
- $e2 = explode('=', $string);
-
- if (isset($e2[0]) && isset($e2[1])) {
- list($key, $value) = $e2;
- $parts[$key] = $value;
- }
- }
- }
-
- return $parts;
- }
-
- protected function _buildDsnPartsArray($dsn)
- {
- // fix sqlite dsn so that it will parse correctly
- $dsn = str_replace("////", "/", $dsn);
- $dsn = str_replace("\\", "/", $dsn);
- $dsn = preg_replace("/\/\/\/(.*):\//", "//$1:/", $dsn);
-
- // silence any warnings
- $parts = @parse_url($dsn);
-
- $names = array('dsn', 'scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment', 'unix_socket');
-
- foreach ($names as $name) {
- if ( ! isset($parts[$name])) {
- $parts[$name] = null;
- }
- }
-
- if (count($parts) == 0 || ! isset($parts['scheme'])) {
- throw new IPF_ORM_Exception('Could not parse dsn');
- }
-
- return $parts;
- }
-
- public function parseDsn($dsn)
- {
- $parts = $this->_buildDsnPartsArray($dsn);
-
- switch ($parts['scheme']) {
- case 'sqlite':
- case 'sqlite2':
- case 'sqlite3':
- if (isset($parts['host']) && $parts['host'] == ':memory') {
- $parts['database'] = ':memory:';
- } else {
- //fix windows dsn we have to add host: to path and set host to null
- if (isset($parts['host'])) {
- $parts['path'] = $parts['host'] . ":" . $parts["path"];
- $parts['host'] = null;
- }
- $parts['database'] = $parts['path'];
- }
-
- $parts['dsn'] = $this->makeDsnForPDO($parts['scheme'], $parts['host'], @$parts['port'], $parts['database']);
-
- break;
-
- case 'mssql':
- case 'dblib':
- if ( ! isset($parts['path']) || $parts['path'] == '/') {
- throw new IPF_ORM_Exception('No database available in data source name');
- }
- if (isset($parts['path'])) {
- $parts['database'] = substr($parts['path'], 1);
- }
- if ( ! isset($parts['host'])) {
- throw new IPF_ORM_Exception('No hostname set in data source name');
- }
-
- $parts['dsn'] = $this->makeDsnForPDO($parts['scheme'], $parts['host'], @$parts['port'], $parts['database']);
-
- break;
-
- case 'mysql':
- case 'informix':
- case 'oci8':
- case 'oci':
- case 'firebird':
- case 'pgsql':
- case 'odbc':
- case 'mock':
- case 'oracle':
- if ( ! isset($parts['path']) || $parts['path'] == '/') {
- throw new IPF_ORM_Exception('No database available in data source name');
- }
- if (isset($parts['path'])) {
- $parts['database'] = substr($parts['path'], 1);
- }
- if ( ! isset($parts['host'])) {
- throw new IPF_ORM_Exception('No hostname set in data source name');
- }
-
- $parts['dsn'] = $this->makeDsnForPDO($parts['scheme'], $parts['host'], @$parts['port'], $parts['database']);
-
- break;
- default:
- throw new IPF_ORM_Exception('Unknown driver '.$parts['scheme']);
- }
-
- return $parts;
- }
-
- public function makeDsnForPDO($driver, $host, $port, $database)
- {
- switch ($driver) {
- case 'sqlite':
- case 'sqlite2':
- case 'sqlite3':
- if ($host == ':memory') {
- return 'sqlite::memory:';
- } else {
- return $driver . ':' . $database;
- }
-
- case 'mssql':
- case 'dblib':
- return $driver . ':host=' . $host . ($port ? ':' . $port : '') . ';dbname=' . $database;
-
- case 'mysql':
- case 'informix':
- case 'oci8':
- case 'oci':
- case 'firebird':
- case 'pgsql':
- case 'odbc':
- case 'mock':
- case 'oracle':
- return $driver . ':host=' . $host . ($port ? ';port=' . $port : '') . ';dbname=' . $database;
-
- default:
- throw new IPF_ORM_Exception('Unknown driver '.$driver);
- }
- }
-
- public function getConnection($name)
- {
- if ( ! isset($this->_connections[$name])) {
- throw new IPF_ORM_Exception('Unknown connection: ' . $name);
- }
-
- return $this->_connections[$name];
- }
-
- public function getConnectionName(IPF_ORM_Connection $conn)
- {
- return array_search($conn, $this->_connections, true);
- }
-
- public function bindComponent($componentName, $connectionName)
- {
- $this->_bound[$componentName] = $connectionName;
- }
-
- public function getConnectionForComponent($componentName)
- {
- //IPF_ORM::autoload($componentName);
-
- if (isset($this->_bound[$componentName])) {
- return $this->getConnection($this->_bound[$componentName]);
- }
-
- return $this->getCurrentConnection();
- }
-
- public function hasConnectionForComponent($componentName = null)
- {
- return isset($this->_bound[$componentName]);
- }
-
- public function closeConnection(IPF_ORM_Connection $connection)
- {
- $connection->close();
-
- $key = array_search($connection, $this->_connections, true);
-
- if ($key !== false) {
- unset($this->_connections[$key]);
- }
- $this->_currIndex = key($this->_connections);
-
- unset($connection);
- }
-
- public function getConnections()
- {
- return $this->_connections;
- }
-
- public function setCurrentConnection($key)
- {
- $key = (string) $key;
- if ( ! isset($this->_connections[$key])) {
- throw new InvalidKeyException();
- }
- $this->_currIndex = $key;
- }
-
- public function contains($key)
- {
- return isset($this->_connections[$key]);
- }
-
- public function count()
- {
- return count($this->_connections);
- }
-
- public function getIterator()
- {
- return new ArrayIterator($this->_connections);
- }
-
public function getCurrentConnection()
{
- $i = $this->_currIndex;
- if ( ! isset($this->_connections[$i])) {
- throw new IPF_ORM_Exception('There is no open connection');
- }
- return $this->_connections[$i];
- }
-
- public function createDatabases($specifiedConnections = array())
- {
- if ( ! is_array($specifiedConnections)) {
- $specifiedConnections = (array) $specifiedConnections;
+ if (!$this->_connection) {
+ $pdo = \PFF\Container::databaseConnection();
+ $this->_connection = new IPF_ORM_Connection_Mysql($this, $pdo);
}
-
- $results = array();
-
- foreach ($this as $name => $connection) {
- if ( ! empty($specifiedConnections) && ! in_array($name, $specifiedConnections)) {
- continue;
- }
-
- $results[$name] = $connection->createDatabase();
- }
-
- return $results;
- }
-
- public function dropDatabases($specifiedConnections = array())
- {
- if ( ! is_array($specifiedConnections)) {
- $specifiedConnections = (array) $specifiedConnections;
- }
-
- $results = array();
-
- foreach ($this as $name => $connection) {
- if ( ! empty($specifiedConnections) && ! in_array($name, $specifiedConnections)) {
- continue;
- }
-
- $results[$name] = $connection->dropDatabase();
- }
-
- return $results;
+ return $this->_connection;
}
public function __toString()
{
- $r[] = "<pre>";
- $r[] = "IPF_ORM_Manager";
- $r[] = "Connections : ".count($this->_connections);
- $r[] = "</pre>";
- return implode("\n",$r);
+ return "<pre>\nIPF_ORM_Manager\n</pre>";
}
}
{
// get the connection for the component
$manager = IPF_ORM_Manager::getInstance();
- if ($manager->hasConnectionForComponent($name)) {
- $this->_conn = $manager->getConnectionForComponent($name);
- }
$table = $this->_conn->getTable($name);
$tableName = $table->getTableName();
{
// get the connection for the component
$manager = IPF_ORM_Manager::getInstance();
- if ($manager->hasConnectionForComponent($name)) {
- $this->_conn = $manager->getConnectionForComponent($name);
- }
$table = $this->_conn->getTable($name);
$tableName = $table->getTableName();
IPF_ORM_Hydrator_Abstract $hydrator = null)
{
if ($connection === null) {
- $connection = IPF_ORM_Manager::getInstance()->getCurrentConnection();
+ $connection = IPF_ORM_Manager::connection();
}
if ($hydrator === null) {
$hydrator = new IPF_ORM_Hydrator();
public function __construct($table)
{
if ( ! ($table instanceof IPF_ORM_Table)) {
- $table = IPF_ORM_Manager::getInstance()
- ->getCurrentConnection()
- ->getTable($table);
+ $table = IPF_ORM_Manager::connection()->getTable($table);
}
$this->table = $table;
$this->_tokenizer = new IPF_ORM_Query_Tokenizer();
{
return $this->sql;
}
-}
\ No newline at end of file
+}
}
if (!isset($table)) {
- $conn = IPF_ORM_Manager::getInstance()
- ->getConnectionForComponent($component);
-
- $table = $conn->getTable($component);
+ $table = IPF_ORM_Manager::connection()->getTable($component);
$this->_queryComponents[$componentAlias] = array('table' => $table);
} else {
$relation = $table->getRelation($component);
$this->preUnserialize($event);
- $manager = IPF_ORM_Manager::getInstance();
- $connection = $manager->getConnectionForComponent(get_class($this));
+ $connection = IPF_ORM_Manager::connection();
$this->_oid = self::$_index;
self::$_index++;
final public function getTable()
{
- return IPF_ORM_Manager::getInstance()
- ->getConnectionForComponent($this->definition['class'])
- ->getTable($this->definition['class']);
+ return IPF_ORM_Manager::connection()->getTable($this->definition['class']);
}
final public function getClass()
public function beginTransaction($savepoint = null)
{
- $this->conn->connect();
-
if ( ! is_null($savepoint)) {
$this->savePoints[] = $savepoint;
if ($this->_nestingLevel == 0) {
throw new IPF_ORM_Exception("Commit failed. There is no active transaction.");
}
-
- $this->conn->connect();
if ( ! is_null($savepoint)) {
$this->_nestingLevel -= $this->removeSavePoints($savepoint);
if ($this->_nestingLevel == 0) {
throw new IPF_ORM_Exception("Rollback failed. There is no active transaction.");
}
-
- $this->conn->connect();
if ($this->_internalNestingLevel > 1 || $this->_nestingLevel > 1) {
$this->_internalNestingLevel--;