Commit edddb0c8 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 97604279
...@@ -36,7 +36,6 @@ class Doctrine_Compiler { ...@@ -36,7 +36,6 @@ class Doctrine_Compiler {
*/ */
private static $classes = array( private static $classes = array(
'Access', 'Access',
'Adapter_Exception',
'Adapter_Interface', 'Adapter_Interface',
'Doctrine', 'Doctrine',
'Configurable', 'Configurable',
...@@ -45,7 +44,6 @@ class Doctrine_Compiler { ...@@ -45,7 +44,6 @@ class Doctrine_Compiler {
'Connection', 'Connection',
'Connection_Exception', 'Connection_Exception',
'Connection_UnitOfWork', 'Connection_UnitOfWork',
'Connection_Transaction',
'DB', 'DB',
'DB_Exception', 'DB_Exception',
'DB_EventListener', 'DB_EventListener',
......
...@@ -35,11 +35,11 @@ ...@@ -35,11 +35,11 @@
*/ */
class Doctrine_Locking_Manager_Pessimistic { class Doctrine_Locking_Manager_Pessimistic {
/** /**
* The datasource that is used by the locking manager * The conn that is used by the locking manager
* *
* @var Doctrine_Connection object * @var Doctrine_Connection object
*/ */
private $_dataSource; private $conn;
/** /**
* The database table name for the lock tracking * The database table name for the lock tracking
*/ */
...@@ -51,20 +51,37 @@ class Doctrine_Locking_Manager_Pessimistic { ...@@ -51,20 +51,37 @@ class Doctrine_Locking_Manager_Pessimistic {
* When the CREATE_TABLES attribute of the connection on which the manager * When the CREATE_TABLES attribute of the connection on which the manager
* is supposed to work on is set to true, the locking table is created. * is supposed to work on is set to true, the locking table is created.
* *
* @param Doctrine_Connection $dataSource The database connection to use * @param Doctrine_Connection $conn The database connection to use
*/ */
public function __construct(Doctrine_Connection $dataSource) { public function __construct(Doctrine_Connection $conn) {
$this->_dataSource = $dataSource; $this->conn = $conn;
if ($this->_dataSource->getAttribute(Doctrine::ATTR_CREATE_TABLES) === true) { if ($this->conn->getAttribute(Doctrine::ATTR_CREATE_TABLES) === true) {
$columns = array(); $columns = array();
$columns['object_type'] = array('string', 50, array('notnull' => true, 'primary' => true)); $columns['object_type'] = array('type' => 'string',
$columns['object_key'] = array('string', 250, array('notnull' => true, 'primary' => true)); 'length' => 50,
$columns['user_ident'] = array('string', 50, array('notnull' => true)); 'notnull' => true,
$columns['timestamp_obtained'] = array('integer', 10, array('notnull' => true)); 'primary' => true);
$dataDict = new Doctrine_DataDict($this->_dataSource->getDBH()); $columns['object_key'] = array('type' => 'string',
$dataDict->createTable($this->_lockTable, $columns); 'length' => 250,
'notnull' => true,
'primary' => true);
$columns['user_ident'] = array('type' => 'string',
'length' => 50,
'notnull' => true);
$columns['timestamp_obtained'] = array('type' => 'integer',
'length' => 10,
'notnull' => true);
$options = array('primary' => array('object_type', 'object_key'));
try {
$this->conn->export->createTable($this->_lockTable, $columns, $options);
} catch(Exception $e) {
}
} }
} }
...@@ -89,7 +106,7 @@ class Doctrine_Locking_Manager_Pessimistic { ...@@ -89,7 +106,7 @@ class Doctrine_Locking_Manager_Pessimistic {
} }
try { try {
$dbh = $this->_dataSource->getDBH(); $dbh = $this->conn->getDBH();
$dbh->beginTransaction(); $dbh->beginTransaction();
$stmt = $dbh->prepare("INSERT INTO $this->_lockTable $stmt = $dbh->prepare("INSERT INTO $this->_lockTable
...@@ -152,7 +169,7 @@ class Doctrine_Locking_Manager_Pessimistic { ...@@ -152,7 +169,7 @@ class Doctrine_Locking_Manager_Pessimistic {
} }
try { try {
$dbh = $this->_dataSource->getDBH(); $dbh = $this->conn->getDbh();
$stmt = $dbh->prepare("DELETE FROM $this->_lockTable WHERE $stmt = $dbh->prepare("DELETE FROM $this->_lockTable WHERE
object_type = :object_type AND object_type = :object_type AND
object_key = :object_key AND object_key = :object_key AND
...@@ -185,7 +202,7 @@ class Doctrine_Locking_Manager_Pessimistic { ...@@ -185,7 +202,7 @@ class Doctrine_Locking_Manager_Pessimistic {
} }
try { try {
$dbh = $this->_dataSource->getDBH(); $dbh = $this->conn->getDbh();
$stmt = $dbh->prepare("SELECT user_ident $stmt = $dbh->prepare("SELECT user_ident
FROM $this->_lockTable FROM $this->_lockTable
WHERE object_type = :object_type AND object_key = :object_key"); WHERE object_type = :object_type AND object_key = :object_key");
...@@ -233,15 +250,15 @@ class Doctrine_Locking_Manager_Pessimistic { ...@@ -233,15 +250,15 @@ class Doctrine_Locking_Manager_Pessimistic {
$age = time() - $age; $age = time() - $age;
try { try {
$dbh = $this->_dataSource->getDBH(); $dbh = $this->conn->getDbh();
$stmt = $dbh->prepare("DELETE FROM $this->_lockTable WHERE timestamp_obtained < :age"); $stmt = $dbh->prepare('DELETE FROM ' . $this->_lockTable . ' WHERE timestamp_obtained < :age');
$stmt->bindParam(':age', $age); $stmt->bindParam(':age', $age);
$query = "DELETE FROM $this->_lockTable WHERE timestamp_obtained < :age"; $query = 'DELETE FROM ' . $this->_lockTable . ' WHERE timestamp_obtained < :age';
if ($objectType) { if ($objectType) {
$query .= " AND object_type = :object_type"; $query .= ' AND object_type = :object_type';
} }
if ($userIdent) { if ($userIdent) {
$query .= " AND user_ident = :user_ident"; $query .= ' AND user_ident = :user_ident';
} }
$stmt = $dbh->prepare($query); $stmt = $dbh->prepare($query);
$stmt->bindParam(':age', $age); $stmt->bindParam(':age', $age);
......
...@@ -775,7 +775,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -775,7 +775,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return string * @return string
*/ */
final public function getTableName() { final public function getTableName() {
return $this->options['tableName']; return $this->conn->quoteIdentifier($this->options['tableName']);
} }
/** /**
* create * create
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment