1
0
mirror of synced 2025-02-08 00:09:26 +03:00
This commit is contained in:
zYne 2006-12-02 20:46:05 +00:00
parent 97604279bf
commit edddb0c86a
3 changed files with 48 additions and 33 deletions

View File

@ -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 {
'Connection', 'Connection',
'Connection_Exception', 'Connection_Exception',
'Connection_UnitOfWork', 'Connection_UnitOfWork',
'Connection_Transaction',
'DB', 'DB',
'DB_Exception', 'DB_Exception',
'DB_EventListener', 'DB_EventListener',

View File

@ -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,21 +51,38 @@ 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);
$columns['object_key'] = array('type' => 'string',
'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);
$dataDict = new Doctrine_DataDict($this->_dataSource->getDBH()); $options = array('primary' => array('object_type', 'object_key'));
$dataDict->createTable($this->_lockTable, $columns); try {
} $this->conn->export->createTable($this->_lockTable, $columns, $options);
} catch(Exception $e) {
}
}
} }
/** /**
@ -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 {
} }
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 {
} }
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,20 +250,20 @@ 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);
if ($objectType) { if ($objectType) {
$stmt->bindParam(':object_type', $objectType); $stmt->bindParam(':object_type', $objectType);
} }
if ($userIdent) { if ($userIdent) {
$stmt->bindParam(':user_ident', $userIdent); $stmt->bindParam(':user_ident', $userIdent);

View File

@ -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