Commit 4e22f1fb authored by lsmith's avatar lsmith

- second round of PEAR CS fixes

parent 716bb65b
......@@ -32,8 +32,9 @@
* @since 1.0
* @version $Revision$
*/
final class Doctrine {
/**
final class Doctrine
{
/**
* ERROR CONSTANTS
*/
const ERR = -1;
......@@ -137,7 +138,7 @@ final class Doctrine {
const ATTR_DEF_TABLESPACE = 32;
const ATTR_EMULATE_DATABASE = 33;
const ATTR_DB_NAME_FORMAT = 34;
/** TODO: REMOVE THE FOLLOWING CONSTANTS AND UPDATE THE DOCS ! */
/**
......@@ -176,8 +177,8 @@ final class Doctrine {
* accessor invoking prefix set
*/
const ATTR_ACCESSOR_PREFIX_SET = 23;
/**
* LIMIT CONSTANTS
......@@ -234,14 +235,14 @@ final class Doctrine {
/**
* FETCH RECORD
*
* Specifies that the fetch method shall return Doctrine_Record
* Specifies that the fetch method shall return Doctrine_Record
* objects as the elements of the result set.
*
* This is the default fetchmode.
*/
const FETCH_RECORD = 2;
/**
* FETCH ARRAY
* FETCH ARRAY
*/
const FETCH_ARRAY = 3;
......@@ -250,7 +251,7 @@ final class Doctrine {
/**
* ACCESSOR CONSTANTS
*/
/**
* constant for no accessors
*/
......@@ -267,7 +268,7 @@ final class Doctrine {
* constant for both accessors get and set
*/
const ACCESSOR_BOTH = 3;
/**
* PORTABILITY CONSTANTS
*/
......@@ -330,7 +331,8 @@ final class Doctrine {
/**
* constructor
*/
public function __construct() {
public function __construct()
{
throw new Doctrine_Exception('Doctrine is static class. No instances can be created.');
}
/**
......@@ -343,7 +345,8 @@ final class Doctrine {
*
* @return string
*/
public static function getPath() {
public static function getPath()
{
if (! self::$path) {
self::$path = dirname(__FILE__);
}
......@@ -355,7 +358,8 @@ final class Doctrine {
*
* @return void
*/
public static function loadAll() {
public static function loadAll()
{
$classes = Doctrine_Compiler::getRuntimeClasses();
foreach ($classes as $class) {
......@@ -368,7 +372,8 @@ final class Doctrine {
*
* @param string $directory
*/
public static function import($directory) {
public static function import($directory)
{
Doctrine_Import::import();
}
/**
......@@ -377,7 +382,8 @@ final class Doctrine {
*
* @param string $directory
*/
public static function export($directory) {
public static function export($directory)
{
Doctrine_Export::export();
}
/**
......@@ -389,7 +395,8 @@ final class Doctrine {
* @throws Doctrine_Exception
* @return void
*/
public static function compile() {
public static function compile()
{
Doctrine_Compiler::compile();
}
/**
......@@ -399,7 +406,8 @@ final class Doctrine {
* @param string $classname
* @return boolean
*/
public static function autoload($classname) {
public static function autoload($classname)
{
if (class_exists($classname)) {
return false;
}
......@@ -422,7 +430,8 @@ final class Doctrine {
* @param string $classname
* @return string
*/
public static function tableize($classname) {
public static function tableize($classname)
{
return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $classname));
}
/**
......@@ -431,7 +440,8 @@ final class Doctrine {
* @param string $tablename
* @return string
*/
public static function classify($tablename) {
public static function classify($tablename)
{
return preg_replace('~(_?)(_)([\w])~e', '"$1".strtoupper("$3")', ucfirst($tablename));
}
/**
......@@ -440,7 +450,8 @@ final class Doctrine {
* @param string $classname
* @return boolean
*/
public static function isValidClassname($classname) {
public static function isValidClassname($classname)
{
if (preg_match('~(^[a-z])|(_[a-z])|([\W])|(_{2})~', $classname))
return false;
......
......@@ -32,7 +32,8 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Access implements ArrayAccess {
abstract class Doctrine_Access implements ArrayAccess
{
/**
* setArray
*
......@@ -40,7 +41,8 @@ abstract class Doctrine_Access implements ArrayAccess {
* @since 1.0
* @return Doctrine_Access
*/
public function setArray(array $array) {
public function setArray(array $array)
{
foreach ($array as $k=>$v) {
$this->set($k,$v);
};
......@@ -56,7 +58,8 @@ abstract class Doctrine_Access implements ArrayAccess {
* @since 1.0
* @return void
*/
public function __set($name,$value) {
public function __set($name,$value)
{
$this->set($name,$value);
}
/**
......@@ -67,7 +70,8 @@ abstract class Doctrine_Access implements ArrayAccess {
* @since 1.0
* @return mixed
*/
public function __get($name) {
public function __get($name)
{
return $this->get($name);
}
/**
......@@ -77,7 +81,8 @@ abstract class Doctrine_Access implements ArrayAccess {
* @since 1.0
* @return boolean whether or not this object contains $name
*/
public function __isset($name) {
public function __isset($name)
{
return $this->contains($name);
}
/**
......@@ -87,14 +92,16 @@ abstract class Doctrine_Access implements ArrayAccess {
* @since 1.0
* @return void
*/
public function __unset($name) {
public function __unset($name)
{
return $this->remove($name);
}
/**
* @param mixed $offset
* @return boolean whether or not this object contains $offset
*/
public function offsetExists($offset) {
public function offsetExists($offset)
{
return $this->contains($offset);
}
/**
......@@ -103,7 +110,8 @@ abstract class Doctrine_Access implements ArrayAccess {
* @param mixed $offset
* @return mixed
*/
public function offsetGet($offset) {
public function offsetGet($offset)
{
return $this->get($offset);
}
/**
......@@ -113,7 +121,8 @@ abstract class Doctrine_Access implements ArrayAccess {
* @param mixed $value
* @return void
*/
public function offsetSet($offset, $value) {
public function offsetSet($offset, $value)
{
if ( ! isset($offset)) {
$this->add($value);
} else {
......@@ -125,7 +134,8 @@ abstract class Doctrine_Access implements ArrayAccess {
* @see set, offsetSet, __set
* @param mixed $offset
*/
public function offsetUnset($offset) {
public function offsetUnset($offset)
{
return $this->remove($offset);
}
}
......@@ -30,7 +30,8 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Adapter {
class Doctrine_Adapter
{
const ATTR_AUTOCOMMIT = 0;
const ATTR_CASE = 8;
const ATTR_CLIENT_VERSION = 5;
......
......@@ -29,22 +29,31 @@
* @since 1.0
* @version $Revision$
*/
abstract class Doctrine_Adapter_Statement {
public function bindValue($no, $value) {
abstract class Doctrine_Adapter_Statement
{
public function bindValue($no, $value)
{
}
public function fetch() {
public function fetch()
{
}
public function nextRowset() {
public function nextRowset()
{
}
public function execute() {
public function execute()
{
}
public function errorCode() {
public function errorCode()
{
}
public function errorInfo() {
public function errorInfo()
{
}
public function rowCount() {
public function rowCount()
{
}
public function setFetchMode($mode) {
public function setFetchMode($mode)
{
}
public function columnCount(){
}
......
......@@ -30,7 +30,8 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Cache_Query_Sqlite implements Countable {
class Doctrine_Cache_Query_Sqlite implements Countable
{
/**
* doctrine cache
*/
......@@ -48,7 +49,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
*
* @param Doctrine_Connection|null $connection
*/
public function __construct($connection = null) {
public function __construct($connection = null)
{
if ( ! ($connection instanceof Doctrine_Connection)) {
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
}
......@@ -81,7 +83,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
* @param integer $lifespan
* @return void
*/
public function store($query, array $result, $lifespan) {
public function store($query, array $result, $lifespan)
{
$sql = "INSERT INTO ".self::CACHE_TABLE." (query_md5, query_result, expires) VALUES (?,?,?)";
$stmt = $this->dbh->prepare($sql);
$params = array(md5($query), serialize($result), (time() + $lifespan));
......@@ -93,7 +96,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
* @param string $md5
* @return array
*/
public function fetch($md5) {
public function fetch($md5)
{
$sql = "SELECT query_result, expires FROM ".self::CACHE_TABLE." WHERE query_md5 = ?";
$stmt = $this->dbh->prepare($sql);
$params = array($md5);
......@@ -107,7 +111,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
*
* @return integer
*/
public function deleteAll() {
public function deleteAll()
{
$sql = "DELETE FROM ".self::CACHE_TABLE;
$stmt = $this->dbh->query($sql);
return $stmt->rowCount();
......@@ -118,7 +123,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
*
* @return integer
*/
public function deleteExpired() {
public function deleteExpired()
{
$sql = "DELETE FROM ".self::CACHE_TABLE." WHERE expired < ?";
$stmt = $this->dbh->prepare($sql);
$stmt->execute(array(time()));
......@@ -131,7 +137,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
* @param string $md5
* @return boolean
*/
public function delete($md5) {
public function delete($md5)
{
$sql = "DELETE FROM ".self::CACHE_TABLE." WHERE query_md5 = ?";
$stmt = $this->dbh->prepare($sql);
$params = array($md5);
......@@ -143,7 +150,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
*
* @return integer
*/
public function count() {
public function count()
{
$stmt = $this->dbh->query("SELECT COUNT(*) FROM ".self::CACHE_TABLE);
$data = $stmt->fetch(PDO::FETCH_NUM);
......
This diff is collapsed.
......@@ -32,7 +32,8 @@ Doctrine::autoload('Doctrine_Collection');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_Collection_Batch extends Doctrine_Collection {
class Doctrine_Collection_Batch extends Doctrine_Collection
{
/**
* @var integer $batchSize batch size
*/
......@@ -42,7 +43,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
*/
private $loaded = array();
public function __construct(Doctrine_Table $table) {
public function __construct(Doctrine_Table $table)
{
parent::__construct($table);
$this->batchSize = $this->getTable()->getAttribute(Doctrine::ATTR_BATCH_SIZE);
}
......@@ -51,7 +53,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
* @param integer $batchSize batch size
* @return boolean
*/
public function setBatchSize($batchSize) {
public function setBatchSize($batchSize)
{
$batchSize = (int) $batchSize;
if ($batchSize <= 0) {
return false;
......@@ -64,7 +67,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
*
* @return integer
*/
public function getBatchSize() {
public function getBatchSize()
{
return $this->batchSize;
}
/**
......@@ -74,7 +78,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
* @param Doctrine_Record $record record to be loaded
* @return boolean whether or not the load operation was successful
*/
public function load(Doctrine_Record $record) {
public function load(Doctrine_Record $record)
{
if (empty($this->data)) {
return false;
}
......@@ -146,7 +151,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
* @param mixed $key the key of the record
* @return object Doctrine_Record record
*/
public function get($key) {
public function get($key)
{
if (isset($this->data[$key])) {
switch (gettype($this->data[$key])) {
case "array":
......@@ -173,7 +179,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
/**
* @return Doctrine_Iterator
*/
public function getIterator() {
public function getIterator()
{
return new Doctrine_Collection_Iterator_Expandable($this);
}
}
......@@ -29,4 +29,5 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection_Exception extends Doctrine_Exception { }
class Doctrine_Collection_Exception extends Doctrine_Exception
{ }
......@@ -9,12 +9,14 @@ Doctrine::autoload('Doctrine_Collection');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_Collection_Immediate extends Doctrine_Collection {
class Doctrine_Collection_Immediate extends Doctrine_Collection
{
/**
* @param Doctrine_DQL_Parser $graph
* @param integer $key
*/
public function __construct(Doctrine_Table $table) {
public function __construct(Doctrine_Table $table)
{
parent::__construct($table);
}
}
......@@ -30,7 +30,8 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Collection_Iterator implements Iterator {
abstract class Doctrine_Collection_Iterator implements Iterator
{
/**
* @var Doctrine_Collection $collection
*/
......@@ -56,7 +57,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
* constructor
* @var Doctrine_Collection $collection
*/
public function __construct(Doctrine_Collection $collection) {
public function __construct(Doctrine_Collection $collection)
{
$this->collection = $collection;
$this->keys = $this->collection->getKeys();
$this->count = $this->collection->count();
......@@ -66,7 +68,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
*
* @return void
*/
public function rewind() {
public function rewind()
{
$this->index = 0;
$i = $this->index;
if (isset($this->keys[$i])) {
......@@ -79,7 +82,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
*
* @return integer
*/
public function key() {
public function key()
{
return $this->key;
}
/**
......@@ -87,7 +91,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
*
* @return Doctrine_Record
*/
public function current() {
public function current()
{
return $this->collection->get($this->key);
}
/**
......@@ -95,7 +100,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
*
* @return void
*/
public function next() {
public function next()
{
$this->index++;
$i = $this->index;
if (isset($this->keys[$i])) {
......
......@@ -30,8 +30,10 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterator {
public function valid() {
class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterator
{
public function valid()
{
if ($this->index < $this->count) {
return true;
} elseif ($this->index == $this->count) {
......
......@@ -30,11 +30,13 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator {
class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator
{
/**
* @return boolean whether or not the iteration will continue
*/
public function valid() {
public function valid()
{
return ($this->index < $this->count);
}
}
......@@ -30,6 +30,8 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection_Iterator_Offset extends Doctrine_Collection_Iterator {
public function valid() { }
class Doctrine_Collection_Iterator_Offset extends Doctrine_Collection_Iterator
{
public function valid()
{ }
}
......@@ -11,13 +11,15 @@ require_once("Batch.php");
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection_Lazy extends Doctrine_Collection_Batch {
class Doctrine_Collection_Lazy extends Doctrine_Collection_Batch
{
/**
* constructor
* @param Doctrine_DQL_Parser $graph
* @param string $key
*/
public function __construct(Doctrine_Table $table) {
public function __construct(Doctrine_Table $table)
{
parent::__construct($table);
parent::setBatchSize(1);
}
......
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Collection_Offset');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Collection_Offset extends Doctrine_Collection {
class Doctrine_Collection_Offset extends Doctrine_Collection
{
/**
* @var integer $limit
*/
......@@ -39,20 +40,23 @@ class Doctrine_Collection_Offset extends Doctrine_Collection {
/**
* @param Doctrine_Table $table
*/
public function __construct(Doctrine_Table $table) {
public function __construct(Doctrine_Table $table)
{
parent::__construct($table);
$this->limit = $table->getAttribute(Doctrine::ATTR_COLL_LIMIT);
}
/**
* @return integer
*/
public function getLimit() {
public function getLimit()
{
return $this->limit;
}
/**
* @return Doctrine_Collection_Iterator_Expandable
*/
public function getIterator() {
public function getIterator()
{
return new Doctrine_Collection_Iterator_Expandable($this);
}
}
......@@ -30,7 +30,8 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Compiler {
class Doctrine_Compiler
{
/**
* @var array $classes an array containing all runtime classes of Doctrine framework
*/
......@@ -109,7 +110,8 @@ class Doctrine_Compiler {
*
* @return array
*/
public static function getRuntimeClasses() {
public static function getRuntimeClasses()
{
return self::$classes;
}
/**
......@@ -120,7 +122,8 @@ class Doctrine_Compiler {
* @throws Doctrine_Compiler_Exception if something went wrong during the compile operation
* @return void
*/
public static function compile($target = null) {
public static function compile($target = null)
{
$path = Doctrine::getPath();
$classes = self::$classes;
......@@ -159,7 +162,7 @@ class Doctrine_Compiler {
// first write the 'compiled' data to a text file, so
// that we can use php_strip_whitespace (which only works on files)
$fp = @fopen($target, 'w');
if ($fp === false) {
throw new Doctrine_Compiler_Exception("Couldn't write compiled data. Failed to open $target");
}
......
......@@ -29,4 +29,5 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Compiler_Exception extends Doctrine_Exception { }
class Doctrine_Compiler_Exception extends Doctrine_Exception
{ }
......@@ -31,7 +31,8 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Configurable {
abstract class Doctrine_Configurable
{
/**
* @var array $attributes an array of containing all attributes
......@@ -60,7 +61,8 @@ abstract class Doctrine_Configurable {
* @throws Doctrine_Exception if the value is invalid
* @return void
*/
public function setAttribute($attribute,$value) {
public function setAttribute($attribute,$value)
{
switch ($attribute) {
case Doctrine::ATTR_BATCH_SIZE:
if ($value < 0) {
......@@ -153,7 +155,8 @@ abstract class Doctrine_Configurable {
* @param Doctrine_EventListener $listener
* @return void
*/
public function setEventListener($listener) {
public function setEventListener($listener)
{
return $this->setListener($listener);
}
/**
......@@ -162,7 +165,8 @@ abstract class Doctrine_Configurable {
* @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Db
*/
public function addListener($listener, $name = null) {
public function addListener($listener, $name = null)
{
if ( ! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) {
$this->attributes[Doctrine::ATTR_LISTENER] = new Doctrine_EventListener_Chain();
}
......@@ -175,7 +179,8 @@ abstract class Doctrine_Configurable {
*
* @return Doctrine_Db_EventListener_Interface|Doctrine_Overloadable
*/
public function getListener() {
public function getListener()
{
if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER])) {
if (isset($this->parent)) {
return $this->parent->getListener();
......@@ -190,7 +195,8 @@ abstract class Doctrine_Configurable {
* @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Db
*/
public function setListener($listener) {
public function setListener($listener)
{
if ( ! ($listener instanceof Doctrine_EventListener_Interface)
&& ! ($listener instanceof Doctrine_Overloadable)
) {
......@@ -206,7 +212,8 @@ abstract class Doctrine_Configurable {
* @param integer $attribute
* @return mixed
*/
public function getAttribute($attribute) {
public function getAttribute($attribute)
{
$attribute = (int) $attribute;
if ($attribute < 1 || $attribute > 23)
......@@ -226,7 +233,8 @@ abstract class Doctrine_Configurable {
*
* @return array
*/
public function getAttributes() {
public function getAttributes()
{
return $this->attributes;
}
/**
......@@ -236,7 +244,8 @@ abstract class Doctrine_Configurable {
* @param Doctrine_Configurable $component
* @return void
*/
public function setParent(Doctrine_Configurable $component) {
public function setParent(Doctrine_Configurable $component)
{
$this->parent = $component;
}
/**
......@@ -245,7 +254,8 @@ abstract class Doctrine_Configurable {
*
* @return Doctrine_Configurable
*/
public function getParent() {
public function getParent()
{
return $this->parent;
}
}
This diff is collapsed.
......@@ -10,7 +10,8 @@ Doctrine::autoload('Doctrine_Connection');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Connection_Common extends Doctrine_Connection {
class Doctrine_Connection_Common extends Doctrine_Connection
{
/**
* Adds an driver-specific LIMIT clause to the query
*
......@@ -18,7 +19,8 @@ class Doctrine_Connection_Common extends Doctrine_Connection {
* @param mixed $limit
* @param mixed $offset
*/
public function modifyLimitQuery($query,$limit = false,$offset = false,$isManip=false) {
public function modifyLimitQuery($query,$limit = false,$offset = false,$isManip=false)
{
if ($limit && $offset) {
$query .= " LIMIT ".$limit." OFFSET ".$offset;
} elseif ($limit && ! $offset) {
......
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Connection');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Connection_Db2 extends Doctrine_Connection {
class Doctrine_Connection_Db2 extends Doctrine_Connection
{
/**
* Adds an driver-specific LIMIT clause to the query
*
......@@ -39,7 +40,8 @@ class Doctrine_Connection_Db2 extends Doctrine_Connection {
* @param integer $offset start reading from given offset
* @return string the modified query
*/
public function modifyLimitQuery($query, $limit, $offset) {
public function modifyLimitQuery($query, $limit, $offset)
{
if ($limit <= 0)
return $sql;
......
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Connection_Exception extends Doctrine_Exception {
class Doctrine_Connection_Exception extends Doctrine_Exception
{
/**
* @var array $errorMessages an array containing messages for portable error codes
*/
......@@ -67,7 +68,7 @@ class Doctrine_Connection_Exception extends Doctrine_Exception {
Doctrine::ERR_LOADMODULE => 'error while including on demand module',
Doctrine::ERR_TRUNCATED => 'truncated',
Doctrine::ERR_DEADLOCK => 'deadlock detected',
);
);
/**
* @see Doctrine::ERR_* constants
* @since 1.0
......@@ -80,7 +81,8 @@ class Doctrine_Connection_Exception extends Doctrine_Exception {
*
* @return integer portable error code
*/
public function getPortableCode() {
public function getPortableCode()
{
return $this->portableCode;
}
/**
......@@ -89,7 +91,8 @@ class Doctrine_Connection_Exception extends Doctrine_Exception {
*
* @return string portable error message
*/
public function getPortableMessage() {
public function getPortableMessage()
{
return self::errorMessage($this->portableCode);
}
/**
......@@ -102,7 +105,8 @@ class Doctrine_Connection_Exception extends Doctrine_Exception {
* @return string error message, or false if the error code was
* not recognized
*/
public static function errorMessage($value = null) {
public static function errorMessage($value = null)
{
return isset(self::$errorMessages[$value]) ?
self::$errorMessages[$value] : self::$errorMessages[Doctrine::ERR];
}
......
......@@ -32,7 +32,8 @@ Doctrine::autoload('Doctrine_Connection');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_Connection_Firebird extends Doctrine_Connection {
class Doctrine_Connection_Firebird extends Doctrine_Connection
{
/**
* @var string $driverName the name of this connection driver
*/
......@@ -43,7 +44,8 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
* @param Doctrine_Manager $manager
* @param PDO $pdo database handle
*/
public function __construct(Doctrine_Manager $manager, $adapter) {
public function __construct(Doctrine_Manager $manager, $adapter)
{
$this->supported = array(
'sequences' => true,
......@@ -82,7 +84,8 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
*
* @return void
*/
public function setCharset($charset) {
public function setCharset($charset)
{
$query = 'SET NAMES '.$this->dbh->quote($charset);
$this->dbh->query($query);
}
......@@ -94,7 +97,8 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
* @param integer $offset start reading from given offset
* @return string modified query
*/
public function modifyLimitQuery($query, $limit, $offset) {
public function modifyLimitQuery($query, $limit, $offset)
{
if ($limit > 0) {
$query = preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i',
"SELECT FIRST $limit SKIP $offset", $query);
......@@ -106,7 +110,8 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
* @param string $sequence
* @return integer
*/
public function getNextID($sequence) {
public function getNextID($sequence)
{
$stmt = $this->query('SELECT UNIQUE FROM ' . $sequence);
$data = $stmt->fetch(PDO::FETCH_NUM);
return $data[0];
......
......@@ -32,7 +32,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver)
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
*/
class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Exception {
class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Exception
{
/**
* @var array $errorCodeMap an array that is used for determining portable
* error code from a native database error code
......@@ -106,7 +107,8 @@ class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Excepti
* @since 1.0
* @return array
*/
public function processErrorInfo(array $errorInfo) {
public function processErrorInfo(array $errorInfo)
{
/**
// todo: are the following lines needed?
// memo for the interbase php module hackers: we need something similar
......
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Connection');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Connection_Informix extends Doctrine_Connection {
class Doctrine_Connection_Informix extends Doctrine_Connection
{
/**
* @var string $driverName the name of this connection driver
*/
......@@ -41,7 +42,8 @@ class Doctrine_Connection_Informix extends Doctrine_Connection {
* @param Doctrine_Manager $manager
* @param PDO $pdo database handle
*/
public function __construct(Doctrine_Manager $manager, $adapter) {
public function __construct(Doctrine_Manager $manager, $adapter)
{
// initialize all driver options
parent::__construct($manager, $adapter);
......
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Connection_Informix_Exception extends Doctrine_Connection_Exception { }
class Doctrine_Connection_Informix_Exception extends Doctrine_Connection_Exception
{ }
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Common');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_Connection_Mock extends Doctrine_Connection_Common {
class Doctrine_Connection_Mock extends Doctrine_Connection_Common
{
/**
* @var string $driverName the name of this connection driver
*/
......@@ -42,7 +43,8 @@ class Doctrine_Connection_Mock extends Doctrine_Connection_Common {
* @param Doctrine_Manager $manager
* @param PDO|Doctrine_Adapter $adapter database handler
*/
public function __construct(Doctrine_Manager $manager, $adapter) {
public function __construct(Doctrine_Manager $manager, $adapter)
{
}
}
......@@ -29,7 +29,8 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Connection_Module {
class Doctrine_Connection_Module
{
/**
* @var Doctrine_Connection $conn Doctrine_Connection object, every connection
* module holds an instance of Doctrine_Connection
......@@ -43,7 +44,8 @@ class Doctrine_Connection_Module {
* @param Doctrine_Connection $conn Doctrine_Connection object, every connection
* module holds an instance of Doctrine_Connection
*/
public function __construct($conn = null) {
public function __construct($conn = null)
{
if ( ! ($conn instanceof Doctrine_Connection)) {
$conn = Doctrine_Manager::getInstance()->getCurrentConnection();
}
......@@ -59,7 +61,8 @@ class Doctrine_Connection_Module {
*
* @return Doctrine_Connection
*/
public function getConnection() {
public function getConnection()
{
return $this->conn;
}
/**
......@@ -68,7 +71,8 @@ class Doctrine_Connection_Module {
*
* @return string the name of this module
*/
public function getModuleName() {
public function getModuleName()
{
return $this->moduleName;
}
}
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_Connection_Mssql extends Doctrine_Connection {
class Doctrine_Connection_Mssql extends Doctrine_Connection
{
/**
* @var string $driverName the name of this connection driver
*/
......@@ -42,7 +43,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
* @param Doctrine_Manager $manager
* @param PDO $pdo database handle
*/
public function __construct(Doctrine_Manager $manager, $adapter) {
public function __construct(Doctrine_Manager $manager, $adapter)
{
// initialize all driver options
$this->supported = array(
'sequences' => 'emulated',
......@@ -75,7 +77,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
*
* @return string quoted identifier string
*/
public function quoteIdentifier($identifier, $checkOption = false) {
public function quoteIdentifier($identifier, $checkOption = false)
{
if ($checkOption && ! $this->options['quote_identifier']) {
return $identifier;
}
......@@ -87,7 +90,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
* @param string $sequence name of the sequence
* @return integer the next value in the given sequence
*/
public function nextId($sequence) {
public function nextId($sequence)
{
$this->query("INSERT INTO $sequence (vapor) VALUES (0)");
$stmt = $this->query("SELECT @@IDENTITY FROM $sequence");
$data = $stmt->fetch(PDO::FETCH_NUM);
......@@ -103,7 +107,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
* @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
* @return string
*/
public function modifyLimitQuery($query, $limit, $offset, $isManip = false) {
public function modifyLimitQuery($query, $limit, $offset, $isManip = false)
{
if ($limit > 0) {
// we need the starting SELECT clause for later
$select = 'SELECT ';
......@@ -154,7 +159,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
* @param string $field name of the field into which a new row was inserted
* @return integer
*/
public function lastInsertID($table = null, $field = null) {
public function lastInsertID($table = null, $field = null)
{
$server_info = $this->getServerVersion();
if (is_array($server_info)
&& !is_null($server_info['major'])
......
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @category Object Relational Mapping
* @link www.phpdoctrine.com
*/
class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception {
class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception
{
/**
* @var array $errorCodeMap an array that is used for determining portable
* error code from a native database error code
......@@ -61,7 +62,8 @@ class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception
* @return boolean whether or not the error info processing was successfull
* (the process is successfull if portable error code was found)
*/
public function processErrorInfo(array $errorInfo) {
public function processErrorInfo(array $errorInfo)
{
$code = $errorInfo[1];
if (isset(self::$errorCodeMap[$code])) {
$this->portableCode = self::$errorCodeMap[$code];
......
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Common');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
{
/**
* @var string $driverName the name of this connection driver
*/
......@@ -42,7 +43,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
* @param Doctrine_Manager $manager
* @param PDO|Doctrine_Adapter $adapter database handler
*/
public function __construct(Doctrine_Manager $manager, $adapter) {
public function __construct(Doctrine_Manager $manager, $adapter)
{
$adapter->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$this->setAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE, 'INNODB');
......@@ -94,7 +96,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
*
* @return void
*/
public function setCharset($charset) {
public function setCharset($charset)
{
$query = 'SET NAMES '.$this->dbh->quote($charset);
$this->dbh->query($query);
}
......@@ -110,7 +113,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
*
* @return integer
*/
public function nextId($seqName, $ondemand = true) {
public function nextId($seqName, $ondemand = true)
{
$sequenceName = $this->quoteIdentifier($this->getSequenceName($seqName), true);
$seqcolName = $this->quoteIdentifier($this->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true);
$query = 'INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES (NULL)';
......@@ -129,7 +133,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
* @param string $seq_name name of the sequence
* @return integer
*/
public function currId($seqName) {
public function currId($seqName)
{
$sequenceName = $this->quoteIdentifier($this->getSequenceName($seqName), true);
$seqcolName = $this->quoteIdentifier($this->options['seqcol_name'], true);
$query = 'SELECT MAX(' . $seqcolName . ') FROM ' . $sequenceName;
......@@ -199,7 +204,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
*
* @return integer the number of affected rows
*/
public function replace($table, array $fields, array $keys) {
public function replace($table, array $fields, array $keys)
{
$count = count($fields);
$query = $values = '';
$keys = $colnum = 0;
......
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @category Object Relational Mapping
* @link www.phpdoctrine.com
*/
class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception {
class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception
{
/**
* @var array $errorCodeMap an array that is used for determining portable
* error code from a native database error code
......@@ -71,7 +72,8 @@ class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception
* @return boolean whether or not the error info processing was successfull
* (the process is successfull if portable error code was found)
*/
public function processErrorInfo(array $errorInfo) {
public function processErrorInfo(array $errorInfo)
{
$code = $errorInfo[1];
if (isset(self::$errorCodeMap[$code])) {
$this->portableCode = self::$errorCodeMap[$code];
......
......@@ -30,13 +30,15 @@ Doctrine::autoload('Doctrine_Connection');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Connection_Oracle extends Doctrine_Connection {
class Doctrine_Connection_Oracle extends Doctrine_Connection
{
/**
* @var string $driverName the name of this connection driver
*/
protected $driverName = 'Oracle';
public function __construct(Doctrine_Manager $manager, $adapter) {
public function __construct(Doctrine_Manager $manager, $adapter)
{
$this->supported = array(
'sequences' => true,
'indexes' => true,
......@@ -76,7 +78,8 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
* @param integer $offset start reading from given offset
* @return string the modified query
*/
public function modifyLimitQuery($query, $limit, $offset) {
public function modifyLimitQuery($query, $limit, $offset)
{
/**
$e = explode("select ",strtolower($query));
$e2 = explode(" from ",$e[1]);
......@@ -107,7 +110,8 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
* @throws PDOException if something went wrong at database level
* @return integer
*/
public function nextId($sequence) {
public function nextId($sequence)
{
$stmt = $this->query('SELECT ' . $sequence . '.nextval FROM dual');
$data = $stmt->fetch(PDO::FETCH_NUM);
return $data[0];
......@@ -119,7 +123,8 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
* @throws PDOException if something went wrong at database level
* @return mixed id
*/
public function currId($sequence) {
public function currId($sequence)
{
$sequence = $this->quoteIdentifier($this->getSequenceName($sequence), true);
$stmt = $this->query('SELECT ' . $sequence . '.currval FROM dual');
$data = $stmt->fetch(PDO::FETCH_NUM);
......
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @category Object Relational Mapping
* @link www.phpdoctrine.com
*/
class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception {
class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception
{
/**
* @var array $errorCodeMap an array that is used for determining portable
* error code from a native database error code
......@@ -66,7 +67,8 @@ class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception
* @return boolean whether or not the error info processing was successfull
* (the process is successfull if portable error code was found)
*/
public function processErrorInfo(array $errorInfo) {
public function processErrorInfo(array $errorInfo)
{
$code = $errorInfo[1];
if (isset(self::$errorCodeMap[$code])) {
$this->portableCode = self::$errorCodeMap[$code];
......
......@@ -31,7 +31,8 @@ Doctrine::autoload("Doctrine_Connection_Common");
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
{
/**
* @var string $driverName the name of this connection driver
*/
......@@ -42,7 +43,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
* @param Doctrine_Manager $manager
* @param PDO $pdo database handle
*/
public function __construct(Doctrine_Manager $manager, $adapter) {
public function __construct(Doctrine_Manager $manager, $adapter)
{
// initialize all driver options
$this->supported = array(
'sequences' => true,
......@@ -82,7 +84,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
*
* @return void
*/
public function setCharset($charset) {
public function setCharset($charset)
{
$query = 'SET NAMES '.$this->dbh->quote($charset);
$this->dbh->query($query);
}
......@@ -91,7 +94,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
* @param string $sequence
* @return integer
*/
public function nextId($sequence) {
public function nextId($sequence)
{
$stmt = $this->dbh->query("SELECT NEXTVAL('$sequence')");
$data = $stmt->fetch(PDO::FETCH_NUM);
return $data[0];
......@@ -102,7 +106,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
* @param string $seq_name name of the sequence
* @return integer
*/
public function currId($sequence) {
public function currId($sequence)
{
$stmt = $this->dbh->query('SELECT last_value FROM '.$sequence);
$data = $stmt->fetch(PDO::FETCH_NUM);
return $data[0];
......@@ -116,7 +121,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
* @param boolean $isManip if the query is a DML query
* @return string modified query
*/
public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) {
public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false)
{
if ($limit > 0) {
$query = rtrim($query);
......@@ -148,7 +154,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
* @param string $native determines if the raw version string should be returned
* @return array|string an array or string with version information
*/
public function getServerVersion($native = false) {
public function getServerVersion($native = false)
{
$query = 'SHOW SERVER_VERSION';
$serverInfo = $this->fetchOne($query);
......
......@@ -32,7 +32,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception {
class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception
{
/**
* @var array $errorRegexps an array that is used for determining portable
* error code from a native database error message
......@@ -90,10 +91,11 @@ class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception
* @since 1.0
* @see Doctrine::ERR_* constants
* @see Doctrine_Connection::$portableCode
* @return boolean whether or not the error info processing was successfull
* @return boolean whether or not the error info processing was successfull
* (the process is successfull if portable error code was found)
*/
public function processErrorInfo(array $errorInfo) {
public function processErrorInfo(array $errorInfo)
{
foreach (self::$errorRegexps as $regexp => $code) {
if (preg_match($regexp, $errorInfo[2])) {
$this->portableCode = $code;
......
......@@ -31,7 +31,8 @@ Doctrine::autoload("Doctrine_Connection_Common");
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
{
/**
* @var string $driverName the name of this connection driver
*/
......@@ -42,7 +43,8 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
* @param Doctrine_Manager $manager
* @param PDO $pdo database handle
*/
public function __construct(Doctrine_Manager $manager, $adapter) {
public function __construct(Doctrine_Manager $manager, $adapter)
{
$this->supported = array(
'sequences' => 'emulated',
......@@ -76,7 +78,8 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
/**
* initializes database functions missing in sqlite
*/
public function initFunctions() {
public function initFunctions()
{
$this->dbh->sqliteCreateFunction('md5', array('Doctrine_Expression_Sqlite', 'md5Impl'), 1);
$this->dbh->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2);
$this->dbh->sqliteCreateFunction('concat', array('Doctrine_Expression_Sqlite', 'concatImpl'));
......@@ -88,7 +91,8 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
* @param string $seq_name name of the sequence
* @return integer the current id in the given sequence
*/
public function currId($sequence) {
public function currId($sequence)
{
$sequence = $this->quoteIdentifier($sequence, true);
$seqColumn = $this->quoteIdentifier($this->options['seqcol_name'], true);
$stmt = $this->dbh->query('SELECT MAX(' . $seqColumn . ') FROM ' . $sequence);
......
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @category Object Relational Mapping
* @link www.phpdoctrine.com
*/
class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception {
class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
{
/**
* @var array $errorRegexps an array that is used for determining portable
* error code from a native database error message
......@@ -62,7 +63,8 @@ class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
* @return boolean whether or not the error info processing was successfull
* (the process is successfull if portable error code was found)
*/
public function processErrorInfo(array $errorInfo) {
public function processErrorInfo(array $errorInfo)
{
foreach (self::$errorRegexps as $regexp => $code) {
if (preg_match($regexp, $errorInfo[2])) {
......
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Connection_Module');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implements IteratorAggregate, Countable {
class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implements IteratorAggregate, Countable
{
/**
* buildFlushTree
* builds a flush tree that is used in transactions
......@@ -42,7 +43,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
* @param array $tables
* @return array
*/
public function buildFlushTree(array $tables) {
public function buildFlushTree(array $tables)
{
$tree = array();
foreach ($tables as $k => $table) {
$k = $k.$table;
......@@ -135,7 +137,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
* @throws PDOException if something went wrong at database level
* @param Doctrine_Record $record
*/
public function saveRelated(Doctrine_Record $record) {
public function saveRelated(Doctrine_Record $record)
{
$saveLater = array();
foreach ($record->getReferences() as $k=>$v) {
$fk = $record->getTable()->getRelation($k);
......@@ -181,7 +184,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
* @param Doctrine_Record $record
* @return void
*/
public function saveAssociations(Doctrine_Record $record) {
public function saveAssociations(Doctrine_Record $record)
{
foreach ($record->getTable()->getRelations() as $rel) {
$table = $rel->getTable();
$alias = $rel->getAlias();
......@@ -196,7 +200,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
* @throws PDOException if something went wrong at database level
* @return void
*/
public function deleteComposites(Doctrine_Record $record) {
public function deleteComposites(Doctrine_Record $record)
{
foreach ($record->getTable()->getRelations() as $fk) {
switch ($fk->getType()) {
case Doctrine_Relation::ONE_COMPOSITE:
......@@ -214,7 +219,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
* @throws PDOException if something went wrong at database level
* @return void
*/
public function saveAll() {
public function saveAll()
{
// get the flush tree
$tree = $this->buildFlushTree($this->conn->getTables());
......@@ -242,7 +248,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
* @param Doctrine_Record $record
* @return boolean
*/
public function update(Doctrine_Record $record) {
public function update(Doctrine_Record $record)
{
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreUpdate($record);
$array = $record->getPrepared();
......@@ -295,7 +302,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
* @param Doctrine_Record $record record to be inserted
* @return boolean
*/
public function insert(Doctrine_Record $record) {
public function insert(Doctrine_Record $record)
{
// listen the onPreInsert event
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreInsert($record);
......@@ -333,7 +341,9 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
return true;
}
public function getIterator() { }
public function getIterator()
{ }
public function count() { }
public function count()
{ }
}
<?php
/*
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
......@@ -27,10 +27,11 @@
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
*/
class Doctrine_DataDict extends Doctrine_Connection_Module {
class Doctrine_DataDict extends Doctrine_Connection_Module
{
/**
* Obtain an array of changes that may need to applied
*
......@@ -38,7 +39,8 @@ class Doctrine_DataDict extends Doctrine_Connection_Module {
* @param array $previous old definition
* @return array containing all changes that will need to be applied
*/
public function compareDefinition($current, $previous) {
public function compareDefinition($current, $previous)
{
$type = !empty($current['type']) ? $current['type'] : null;
if (!method_exists($this, "_compare{$type}Definition")) {
......
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_DataDict_Exception extends Doctrine_Exception { }
class Doctrine_DataDict_Exception extends Doctrine_Exception
{ }
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_DataDict');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
class Doctrine_DataDict_Firebird extends Doctrine_DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
......@@ -53,7 +54,8 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getNativeDeclaration($field) {
public function getNativeDeclaration($field)
{
switch ($field['type']) {
case 'varchar':
case 'string':
......@@ -96,7 +98,8 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
* @param array $field native field description
* @return array containing the various possible types, length, sign, fixed
*/
public function getPortableDeclaration($field) {
public function getPortableDeclaration($field)
{
$length = $field['length'];
if ((int) $length <= 0)
......@@ -181,7 +184,8 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
* of a field declaration.
*/
public function getCharsetFieldDeclaration($charset) {
public function getCharsetFieldDeclaration($charset)
{
return 'CHARACTER SET '.$charset;
}
/**
......@@ -192,7 +196,8 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion needed to set the COLLATION
* of a field declaration.
*/
public function getCollationFieldDeclaration($collation) {
public function getCollationFieldDeclaration($collation)
{
return 'COLLATE '.$collation;
}
}
......@@ -29,7 +29,8 @@ Doctrine::autoload('Doctrine_DataDict');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_DataDict_Informix extends Doctrine_DataDict {
class Doctrine_DataDict_Informix extends Doctrine_DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
......@@ -53,7 +54,8 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getNativeDeclaration($field) {
public function getNativeDeclaration($field)
{
switch ($field['type']) {
case 'char':
case 'varchar':
......@@ -63,7 +65,7 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict {
if (empty($field['length']) && array_key_exists('default', $field)) {
$field['length'] = $this->conn->varchar_max_length;
}
$length = (! empty($field['length'])) ? $field['length'] : false;
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
......
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Informix_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_DataDict_Informix_Exception extends Doctrine_DataDict_Exception { }
class Doctrine_DataDict_Informix_Exception extends Doctrine_DataDict_Exception
{ }
......@@ -31,11 +31,12 @@ Doctrine::autoload('Doctrine_DataDict');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_DataDict_Mssql extends Doctrine_DataDict {
class Doctrine_DataDict_Mssql extends Doctrine_DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
*
*
* @param array $field associative array with the name of the properties
* of the field being declared as array indexes. Currently, the types
* of supported field properties are as follows:
......@@ -55,7 +56,8 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getNativeDeclaration($field) {
public function getNativeDeclaration($field)
{
switch ($field['type']) {
case 'array':
case 'object':
......@@ -65,7 +67,7 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict {
case 'string':
$length = !empty($field['length'])
? $field['length'] : false;
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')')
......@@ -111,7 +113,8 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict {
* @param array $field native field description
* @return array containing the various possible types, length, sign, fixed
*/
public function getPortableDeclaration($field) {
public function getPortableDeclaration($field)
{
$db_type = preg_replace('/\d/','', strtolower($field['type']) );
$length = $field['length'];
if ((int)$length <= 0) {
......
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_DataDict_Mssql_Exception extends Doctrine_DataDict_Exception { }
class Doctrine_DataDict_Mssql_Exception extends Doctrine_DataDict_Exception
{ }
......@@ -29,7 +29,8 @@ Doctrine::autoload('Doctrine_DataDict');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
class Doctrine_DataDict_Mysql extends Doctrine_DataDict
{
protected $keywords = array(
'ADD', 'ALL', 'ALTER',
'ANALYZE', 'AND', 'AS',
......@@ -130,7 +131,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getNativeDeclaration($field)
public function getNativeDeclaration($field)
{
switch ($field['type']) {
case 'char':
......@@ -218,7 +219,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
* @param array $field native field description
* @return array containing the various possible types, length, sign, fixed
*/
public function getPortableDeclaration(array $field) {
public function getPortableDeclaration(array $field)
{
$dbType = strtolower($field['type']);
$dbType = strtok($dbType, '(), ');
if ($dbType == 'national') {
......@@ -362,7 +364,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
* of a field declaration.
*/
public function getCharsetFieldDeclaration($charset) {
public function getCharsetFieldDeclaration($charset)
{
return 'CHARACTER SET '.$charset;
}
/**
......@@ -373,7 +376,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion needed to set the COLLATION
* of a field declaration.
*/
public function getCollationFieldDeclaration($collation) {
public function getCollationFieldDeclaration($collation)
{
return 'COLLATE '.$collation;
}
/**
......@@ -401,7 +405,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getIntegerDeclaration($name, $field) {
public function getIntegerDeclaration($name, $field)
{
$default = $autoinc = '';
if (!empty($field['autoincrement'])) {
$autoinc = ' AUTO_INCREMENT PRIMARY KEY';
......@@ -410,7 +415,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
$field['default'] = empty($field['notnull']) ? null : 0;
}
$default = ' DEFAULT '.$this->conn->getDbh()->quote($field['default']);
}
}
/**
elseif (empty($field['notnull'])) {
$default = ' DEFAULT NULL';
......
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_DataDict_Mysql_Exception extends Doctrine_DataDict_Exception { }
class Doctrine_DataDict_Mysql_Exception extends Doctrine_DataDict_Exception
{ }
......@@ -27,7 +27,8 @@
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_DataDict_Oracle extends Doctrine_DataDict {
class Doctrine_DataDict_Oracle extends Doctrine_DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
......@@ -50,7 +51,8 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getNativeDeclaration(array $field) {
public function getNativeDeclaration(array $field)
{
switch ($field['type']) {
case 'string':
case 'array':
......@@ -93,7 +95,8 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict {
* @return array containing the various possible types, length, sign, fixed
* @throws Doctrine_DataDict_Oracle_Exception
*/
public function getPortableDeclaration(array $field) {
public function getPortableDeclaration(array $field)
{
$db_type = strtolower($field['type']);
$type = array();
$length = $unsigned = $fixed = null;
......
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_DataDict_Oracle_Exception extends Doctrine_DataDict_Exception { }
class Doctrine_DataDict_Oracle_Exception extends Doctrine_DataDict_Exception
{ }
......@@ -29,7 +29,8 @@
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
{
/**
* @param array $reservedKeyWords an array of reserved keywords by pgsql
*/
......@@ -329,7 +330,7 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
'work',
'write',
'year',
'zone'
'zone'
);
/**
......@@ -350,12 +351,13 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
*
* notnull
* Boolean flag that indicates whether this field is constrained
* to not be set to null.
* to not be set to null.
*
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getNativeDeclaration(array $field) {
public function getNativeDeclaration(array $field)
{
switch ($field['type']) {
case 'char':
case 'string':
......@@ -420,7 +422,8 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
*
* @return array containing the various possible types, length, sign, fixed
*/
public function getPortableDeclaration(array $field) {
public function getPortableDeclaration(array $field)
{
$length = $field['length'];
if ($length == '-1' && isset($field['atttypmod'])) {
......@@ -554,7 +557,8 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getIntegerDeclaration($name, $field) {
public function getIntegerDeclaration($name, $field)
{
/**
if (!empty($field['unsigned'])) {
$db->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer";
......@@ -572,8 +576,8 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
$field['default'] = empty($field['notnull']) ? null : 0;
}
$default = ' DEFAULT '.$this->conn->quote($field['default'], $field['type']);
}
/**
}
/**
TODO: is this needed ?
elseif (empty($field['notnull'])) {
$default = ' DEFAULT NULL';
......
......@@ -22,12 +22,13 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
/**
* Doctrine_DataDict_Pgsql_Exception
*
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_DataDict_Pgsql_Exception extends Doctrine_DataDict_Exception { }
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_DataDict_Pgsql_Exception extends Doctrine_DataDict_Exception
{ }
......@@ -29,7 +29,8 @@ Doctrine::autoload('Doctrine_DataDict');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
class Doctrine_DataDict_Sqlite extends Doctrine_DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
......@@ -53,7 +54,8 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getNativeDeclaration(array $field) {
public function getNativeDeclaration(array $field)
{
switch ($field['type']) {
case 'text':
case 'object':
......@@ -118,7 +120,8 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
* @param array $field native field description
* @return array containing the various possible types, length, sign, fixed
*/
public function getPortableDeclaration(array $field) {
public function getPortableDeclaration(array $field)
{
$dbType = strtolower($field['type']);
$length = ( ! empty($field['length'])) ? $field['length'] : null;
$unsigned = ( ! empty($field['unsigned'])) ? $field['unsigned'] : null;
......@@ -250,7 +253,8 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
* declare the specified field.
* @access protected
*/
public function getIntegerDeclaration($name, array $field) {
public function getIntegerDeclaration($name, array $field)
{
$default = $autoinc = '';
$type = $this->getNativeDeclaration($field);
......@@ -274,4 +278,4 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
$name = $this->conn->quoteIdentifier($name, true);
return $name . ' ' . $type . $unsigned . $default . $notnull . $autoinc;
}
}
}
......@@ -22,12 +22,13 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
/**
* Doctrine_DataDict_Sqlite_Exception
*
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_DataDict_Sqlite_Exception extends Doctrine_DataDict_Exception { }
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_DataDict_Sqlite_Exception extends Doctrine_DataDict_Exception
{ }
......@@ -48,7 +48,8 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Interface {
class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Interface
{
/**
* @var array $instances all the instances of this class
*/
......@@ -91,7 +92,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
* @param string $user database username
* @param string $pass database password
*/
public function __construct($dsn, $user, $pass) {
public function __construct($dsn, $user, $pass)
{
if ( ! isset($user)) {
$a = self::parseDSN($dsn);
......@@ -103,22 +105,26 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
$this->listener = new Doctrine_Db_EventListener();
}
public function nextQuerySequence() {
public function nextQuerySequence()
{
return ++$this->querySequence;
}
/**
* getQuerySequence
*/
public function getQuerySequence() {
public function getQuerySequence()
{
return $this->querySequence;
}
/**
* getDBH
*/
public function getDBH() {
public function getDBH()
{
return $this->dbh;
}
public function getOption($name) {
public function getOption($name)
{
if ( ! array_key_exists($name, $this->options)) {
throw new Doctrine_Db_Exception('Unknown option ' . $name);
}
......@@ -130,7 +136,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
* @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Db
*/
public function addListener($listener, $name = null) {
public function addListener($listener, $name = null)
{
if ( ! ($this->listener instanceof Doctrine_Db_EventListener_Chain)) {
$this->listener = new Doctrine_Db_EventListener_Chain();
}
......@@ -143,7 +150,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return Doctrine_Db_EventListener_Interface|Doctrine_Overloadable
*/
public function getListener() {
public function getListener()
{
return $this->listener;
}
/**
......@@ -152,7 +160,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
* @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Db
*/
public function setListener($listener) {
public function setListener($listener)
{
if ( ! ($listener instanceof Doctrine_Db_EventListener_Interface)
&& ! ($listener instanceof Doctrine_Overloadable)
) {
......@@ -169,7 +178,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return boolean
*/
public function connect() {
public function connect()
{
if ($this->isConnected)
return false;
......@@ -188,7 +198,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return
*/
public static function getConnection($dsn = null, $username = null, $password = null) {
public static function getConnection($dsn = null, $username = null, $password = null)
{
return new self($dsn, $username, $password);
}
/**
......@@ -199,7 +210,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
* @param string $name
* @return string
*/
public static function driverName($name) {
public static function driverName($name)
{
if (isset(self::$driverMap[$name])) {
return self::$driverMap[$name];
}
......@@ -211,7 +223,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
* @param string $dsn
* @return array Parsed contents of DSN
*/
function parseDSN($dsn) {
function parseDSN($dsn)
{
// silence any warnings
$parts = @parse_url($dsn);
......@@ -271,7 +284,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return void
*/
public static function clear() {
public static function clear()
{
self::$instances = array();
}
......@@ -281,7 +295,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return integer
*/
public function errorCode() {
public function errorCode()
{
return $this->dbh->errorCode();
}
/**
......@@ -290,7 +305,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return array
*/
public function errorInfo() {
public function errorInfo()
{
return $this->dbh->errorInfo();
}
/**
......@@ -298,7 +314,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @param string $statement
*/
public function prepare($statement) {
public function prepare($statement)
{
$this->connect();
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::PREPARE, $statement);
......@@ -345,7 +362,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
* @param string $input
* @return string
*/
public function quote($input) {
public function quote($input)
{
$this->connect();
return $this->dbh->quote($input);
......@@ -357,7 +375,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
* @param string $statement
* @return integer
*/
public function exec($statement) {
public function exec($statement)
{
$this->connect();
$args = func_get_args();
......@@ -378,7 +397,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return integer
*/
public function lastInsertId() {
public function lastInsertId()
{
$this->connect();
return $this->dbh->lastInsertId();
......@@ -388,7 +408,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return boolean
*/
public function beginTransaction() {
public function beginTransaction()
{
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::BEGIN);
$this->listener->onPreBeginTransaction($event);
......@@ -404,7 +425,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return boolean
*/
public function commit() {
public function commit()
{
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::COMMIT);
$this->listener->onPreCommit($event);
......@@ -420,7 +442,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return boolean
*/
public function rollBack() {
public function rollBack()
{
$this->connect();
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::ROLLBACK);
......@@ -438,7 +461,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
* @param integer $attribute
* @return mixed
*/
public function getAttribute($attribute) {
public function getAttribute($attribute)
{
$this->connect();
return $this->dbh->getAttribute($attribute);
......@@ -446,7 +470,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
/**
* returns an array of available PDO drivers
*/
public static function getAvailableDrivers() {
public static function getAvailableDrivers()
{
return PDO::getAvailableDrivers();
}
/**
......@@ -457,7 +482,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
* @param mixed $value
* @return boolean
*/
public function setAttribute($attribute, $value) {
public function setAttribute($attribute, $value)
{
$this->connect();
$this->dbh->setAttribute($attribute, $value);
......@@ -467,7 +493,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return ArrayIterator
*/
public function getIterator() {
public function getIterator()
{
if ($this->listener instanceof Doctrine_Db_Profiler)
return $this->listener;
}
......@@ -477,7 +504,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
*
* @return integer
*/
public function count() {
public function count()
{
return $this->querySequence;
}
}
......@@ -29,7 +29,8 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_Event {
class Doctrine_Db_Event
{
const QUERY = 1;
const EXEC = 2;
const EXECUTE = 3;
......@@ -47,28 +48,35 @@ class Doctrine_Db_Event {
protected $endedMicrotime;
public function __construct($invoker, $type, $query = null) {
public function __construct($invoker, $type, $query = null)
{
$this->invoker = $invoker;
$this->type = $type;
$this->query = $query;
}
public function getQuery() {
public function getQuery()
{
return $this->query;
}
public function getType() {
public function getType()
{
return $this->type;
}
public function start() {
public function start()
{
$this->startedMicrotime = microtime(true);
}
public function hasEnded() {
public function hasEnded()
{
return ($this->endedMicrotime != null);
}
public function end() {
public function end()
{
$this->endedMicrotime = microtime(true);
}
public function getInvoker() {
public function getInvoker()
{
return $this->invoker;
}
/**
......@@ -77,7 +85,8 @@ class Doctrine_Db_Event {
*
* @return mixed
*/
public function getElapsedSecs() {
public function getElapsedSecs()
{
if (is_null($this->endedMicrotime)) {
return false;
}
......
......@@ -21,33 +21,48 @@
/**
* Doctrine_Db_EventListener
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_EventListener implements Doctrine_Db_EventListener_Interface {
public function onPreQuery(Doctrine_Db_Event $event) { }
public function onQuery(Doctrine_Db_Event $event) { }
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_EventListener implements Doctrine_Db_EventListener_Interface
{
public function onPreQuery(Doctrine_Db_Event $event)
{ }
public function onQuery(Doctrine_Db_Event $event)
{ }
public function onPrePrepare(Doctrine_Db_Event $event) { }
public function onPrepare(Doctrine_Db_Event $event) { }
public function onPrePrepare(Doctrine_Db_Event $event)
{ }
public function onPrepare(Doctrine_Db_Event $event)
{ }
public function onPreCommit(Doctrine_Db_Event $event) { }
public function onCommit(Doctrine_Db_Event $event) { }
public function onPreCommit(Doctrine_Db_Event $event)
{ }
public function onCommit(Doctrine_Db_Event $event)
{ }
public function onPreExec(Doctrine_Db_Event $event) { }
public function onExec(Doctrine_Db_Event $event) { }
public function onPreExec(Doctrine_Db_Event $event)
{ }
public function onExec(Doctrine_Db_Event $event)
{ }
public function onPreRollBack(Doctrine_Db_Event $event) { }
public function onRollBack(Doctrine_Db_Event $event) { }
public function onPreRollBack(Doctrine_Db_Event $event)
{ }
public function onRollBack(Doctrine_Db_Event $event)
{ }
public function onPreBeginTransaction(Doctrine_Db_Event $event) { }
public function onBeginTransaction(Doctrine_Db_Event $event) { }
public function onPreBeginTransaction(Doctrine_Db_Event $event)
{ }
public function onBeginTransaction(Doctrine_Db_Event $event)
{ }
public function onPreExecute(Doctrine_Db_Event $event) { }
public function onExecute(Doctrine_Db_Event $event) { }
public function onPreExecute(Doctrine_Db_Event $event)
{ }
public function onExecute(Doctrine_Db_Event $event)
{ }
}
......@@ -31,10 +31,12 @@ Doctrine::autoload('Doctrine_Access');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrine_Db_EventListener_Interface {
class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrine_Db_EventListener_Interface
{
private $listeners = array();
public function add($listener, $name = null) {
public function add($listener, $name = null)
{
if ( ! ($listener instanceof Doctrine_Db_EventListener_Interface)
&& ! ($listener instanceof Doctrine_Overloadable)
) {
......@@ -47,14 +49,16 @@ class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrin
}
}
public function get($name) {
public function get($name)
{
if ( ! isset($this->listeners[$name])) {
throw new Doctrine_Db_Exception("Unknown listener $name");
}
return $this->listeners[$name];
}
public function set($name, $listener) {
public function set($name, $listener)
{
if ( ! ($listener instanceof Doctrine_Db_EventListener_Interface)
&& ! ($listener instanceof Doctrine_Overloadable)
) {
......@@ -63,78 +67,92 @@ class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrin
$this->listeners[$name] = $listener;
}
public function onQuery(Doctrine_Db_Event $event) {
public function onQuery(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onQuery($event);
}
}
public function onPreQuery(Doctrine_Db_Event $event) {
public function onPreQuery(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onPreQuery($event);
}
}
public function onPreExec(Doctrine_Db_Event $event) {
public function onPreExec(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onPreExec($event);
}
}
public function onExec(Doctrine_Db_Event $event) {
public function onExec(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onExec($event);
}
}
public function onPrePrepare(Doctrine_Db_Event $event) {
public function onPrePrepare(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onPrePrepare($event);
}
}
public function onPrepare(Doctrine_Db_Event $event) {
public function onPrepare(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onPrepare($event);
}
}
public function onPreCommit(Doctrine_Db_Event $event) {
public function onPreCommit(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onPreCommit($event);
}
}
public function onCommit(Doctrine_Db_Event $event) {
public function onCommit(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onCommit($event);
}
}
public function onPreRollBack(Doctrine_Db_Event $event) {
public function onPreRollBack(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onPreRollBack($event);
}
}
public function onRollBack(Doctrine_Db_Event $event) {
public function onRollBack(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onRollBack($event);
}
}
public function onPreBeginTransaction(Doctrine_Db_Event $event) {
public function onPreBeginTransaction(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onPreBeginTransaction($event);
}
}
public function onBeginTransaction(Doctrine_Db_Event $event) {
public function onBeginTransaction(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onBeginTransaction($event);
}
}
public function onPreExecute(Doctrine_Db_Event $event) {
public function onPreExecute(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onPreExecute($event);
}
}
public function onExecute(Doctrine_Db_Event $event) {
public function onExecute(Doctrine_Db_Event $event)
{
foreach ($this->listeners as $listener) {
$listener->onExecute($event);
}
......
......@@ -30,6 +30,7 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_Exception extends Doctrine_Exception {
class Doctrine_Db_Exception extends Doctrine_Exception
{
}
......@@ -29,7 +29,8 @@ Doctrine::autoload('Doctrine_Db');
* @link www.phpdoctrine.com
* @since 1.0
*/
class Doctrine_Db_Mock extends Doctrine_Db {
class Doctrine_Db_Mock extends Doctrine_Db
{
protected static $errorCodeMap = array(
1004 => Doctrine::ERR_CANNOT_CREATE,
1005 => Doctrine::ERR_CANNOT_CREATE,
......
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Overloadable');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_Profiler implements Doctrine_Overloadable {
class Doctrine_Db_Profiler implements Doctrine_Overloadable
{
/**
* @param array $listeners an array containing all availible listeners
*/
......@@ -56,7 +57,8 @@ class Doctrine_Db_Profiler implements Doctrine_Overloadable {
* @see Doctrine_Db_EventListener
* @return void
*/
public function __call($m, $a) {
public function __call($m, $a)
{
// first argument should be an instance of Doctrine_Db_Event
if ( ! ($a[0] instanceof Doctrine_Db_Event)) {
throw new Doctrine_Db_Profiler_Exception("Couldn't listen event. Event should be an instance of Doctrine_Db_Event.");
......@@ -83,7 +85,8 @@ class Doctrine_Db_Profiler implements Doctrine_Overloadable {
*
* @return Doctrine_Db_Event
*/
public function lastEvent() {
public function lastEvent()
{
if (empty($this->events)) {
return false;
}
......
......@@ -22,12 +22,13 @@ Doctrine::autoload('Doctrine_Db_Exception');
/**
* Doctrine_Db_Exception
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_Profiler_Exception extends Doctrine_Db_Exception { }
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_Profiler_Exception extends Doctrine_Db_Exception
{ }
......@@ -29,7 +29,8 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_Profiler_Query {
class Doctrine_Db_Profiler_Query
{
/**
* @var string SQL query string or user comment, set by $query argument in constructor.
*/
......@@ -60,7 +61,8 @@ class Doctrine_Db_Profiler_Query {
* @param string $query
* @param int $queryType
*/
public function __construct($query, $prepareTime = null) {
public function __construct($query, $prepareTime = null)
{
$this->query = $query;
if ($prepareTime !== null) {
$this->prepareTime = $prepareTime;
......@@ -68,7 +70,8 @@ class Doctrine_Db_Profiler_Query {
$this->startedMicrotime = microtime(true);
}
}
public function start() {
public function start()
{
$this->startedMicrotime = microtime(true);
}
/**
......@@ -76,12 +79,14 @@ class Doctrine_Db_Profiler_Query {
*
* @return bool
*/
public function end() {
public function end()
{
$this->endedMicrotime = microtime(true);
return true;
}
public function getPrepareTime() {
public function getPrepareTime()
{
return $this->prepareTime;
}
......@@ -90,7 +95,8 @@ class Doctrine_Db_Profiler_Query {
*
* @return bool
*/
public function hasEnded() {
public function hasEnded()
{
return ($this->endedMicrotime != null);
}
......@@ -99,7 +105,8 @@ class Doctrine_Db_Profiler_Query {
*
* @return string
*/
public function getQuery() {
public function getQuery()
{
return $this->query;
}
......@@ -108,7 +115,8 @@ class Doctrine_Db_Profiler_Query {
*
* @return int
*/
public function getQueryType() {
public function getQueryType()
{
return $this->queryType;
}
/**
......@@ -117,7 +125,8 @@ class Doctrine_Db_Profiler_Query {
*
* @return mixed
*/
public function getElapsedSecs() {
public function getElapsedSecs()
{
if (is_null($this->endedMicrotime) && ! $this->prepareTime) {
return false;
}
......
......@@ -29,7 +29,8 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_Statement extends PDOStatement {
class Doctrine_Db_Statement extends PDOStatement
{
protected $dbh;
protected $querySequence;
......@@ -38,28 +39,34 @@ class Doctrine_Db_Statement extends PDOStatement {
protected $executed = false;
protected function __construct($dbh) {
protected function __construct($dbh)
{
$this->dbh = $dbh;
$this->baseSequence = $this->querySequence = $this->dbh->getQuerySequence();
}
public function getQuerySequence() {
public function getQuerySequence()
{
return $this->querySequence;
}
public function getBaseSequence() {
public function getBaseSequence()
{
return $this->baseSequence;
}
public function getQuery() {
public function getQuery()
{
return $this->queryString;
}
public function isExecuted($executed = null) {
public function isExecuted($executed = null)
{
if ($executed === null)
return $this->executed;
$this->executed = (bool) $executed;
}
public function execute(array $params = null) {
public function execute(array $params = null)
{
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::EXECUTE, $this->queryString);
$this->dbh->getListener()->onPreExecute($event);
......
......@@ -32,54 +32,84 @@ Doctrine::autoload('Doctrine_EventListener_Interface');
* @since 1.0
* @version $Revision$
*/
class Doctrine_EventListener implements Doctrine_EventListener_Interface {
class Doctrine_EventListener implements Doctrine_EventListener_Interface
{
public function onLoad(Doctrine_Record $record) { }
public function onPreLoad(Doctrine_Record $record) { }
public function onLoad(Doctrine_Record $record)
{ }
public function onPreLoad(Doctrine_Record $record)
{ }
public function onSleep(Doctrine_Record $record) { }
public function onSleep(Doctrine_Record $record)
{ }
public function onWakeUp(Doctrine_Record $record) { }
public function onWakeUp(Doctrine_Record $record)
{ }
public function onUpdate(Doctrine_Record $record) { }
public function onPreUpdate(Doctrine_Record $record) { }
public function onUpdate(Doctrine_Record $record)
{ }
public function onPreUpdate(Doctrine_Record $record)
{ }
public function onCreate(Doctrine_Record $record) { }
public function onPreCreate(Doctrine_Record $record) { }
public function onCreate(Doctrine_Record $record)
{ }
public function onPreCreate(Doctrine_Record $record)
{ }
public function onSave(Doctrine_Record $record) { }
public function onPreSave(Doctrine_Record $record) { }
public function onSave(Doctrine_Record $record)
{ }
public function onPreSave(Doctrine_Record $record)
{ }
public function onGetProperty(Doctrine_Record $record, $property, $value) {
public function onGetProperty(Doctrine_Record $record, $property, $value)
{
return $value;
}
public function onSetProperty(Doctrine_Record $record, $property, $value) {
public function onSetProperty(Doctrine_Record $record, $property, $value)
{
return $value;
}
public function onInsert(Doctrine_Record $record) { }
public function onPreInsert(Doctrine_Record $record) { }
public function onDelete(Doctrine_Record $record) { }
public function onPreDelete(Doctrine_Record $record) { }
public function onEvict(Doctrine_Record $record) { }
public function onPreEvict(Doctrine_Record $record) { }
public function onClose(Doctrine_Connection $connection) { }
public function onPreClose(Doctrine_Connection $connection) { }
public function onOpen(Doctrine_Connection $connection) { }
public function onTransactionCommit(Doctrine_Connection $connection) { }
public function onPreTransactionCommit(Doctrine_Connection $connection) { }
public function onTransactionRollback(Doctrine_Connection $connection) { }
public function onPreTransactionRollback(Doctrine_Connection $connection) { }
public function onTransactionBegin(Doctrine_Connection $connection) { }
public function onPreTransactionBegin(Doctrine_Connection $connection) { }
public function onCollectionDelete(Doctrine_Collection $collection) { }
public function onPreCollectionDelete(Doctrine_Collection $collection) { }
public function onInsert(Doctrine_Record $record)
{ }
public function onPreInsert(Doctrine_Record $record)
{ }
public function onDelete(Doctrine_Record $record)
{ }
public function onPreDelete(Doctrine_Record $record)
{ }
public function onEvict(Doctrine_Record $record)
{ }
public function onPreEvict(Doctrine_Record $record)
{ }
public function onClose(Doctrine_Connection $connection)
{ }
public function onPreClose(Doctrine_Connection $connection)
{ }
public function onOpen(Doctrine_Connection $connection)
{ }
public function onTransactionCommit(Doctrine_Connection $connection)
{ }
public function onPreTransactionCommit(Doctrine_Connection $connection)
{ }
public function onTransactionRollback(Doctrine_Connection $connection)
{ }
public function onPreTransactionRollback(Doctrine_Connection $connection)
{ }
public function onTransactionBegin(Doctrine_Connection $connection)
{ }
public function onPreTransactionBegin(Doctrine_Connection $connection)
{ }
public function onCollectionDelete(Doctrine_Collection $collection)
{ }
public function onPreCollectionDelete(Doctrine_Collection $collection)
{ }
}
......@@ -22,15 +22,16 @@ Doctrine::autoload('Doctrine_EventListener');
/**
* Doctrine_EventListener_AccessorInvoker
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_EventListener_AccessorInvoker extends Doctrine_EventListener {
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_EventListener_AccessorInvoker extends Doctrine_EventListener
{
/**
* @var boolean $lockGetCall a simple variable to prevent recursion
*/
......@@ -47,7 +48,8 @@ class Doctrine_EventListener_AccessorInvoker extends Doctrine_EventListener {
* @param mixed $value
* @return mixed
*/
public function onGetProperty(Doctrine_Record $record, $property, $value) {
public function onGetProperty(Doctrine_Record $record, $property, $value)
{
$method = 'get' . ucwords($property);
if (method_exists($record, $method) && ! $this->lockGetCall) {
......@@ -67,7 +69,8 @@ class Doctrine_EventListener_AccessorInvoker extends Doctrine_EventListener {
* @param mixed $value
* @return mixed
*/
public function onSetProperty(Doctrine_Record $record, $property, $value) {
public function onSetProperty(Doctrine_Record $record, $property, $value)
{
$method = 'set' . ucwords($property);
if (method_exists($record, $method) && ! $this->lockSetCall) {
......
This diff is collapsed.
<?php
Doctrine::autoload("EventListener");
class Doctrine_DebugMessage {
class Doctrine_DebugMessage
{
private $code;
private $object;
public function __construct($object, $code) {
public function __construct($object, $code)
{
$this->object = $object;
$this->code = $code;
}
final public function getCode() {
final public function getCode()
{
return $this->code;
}
final public function getObject() {
final public function getObject()
{
return $this->object;
}
}
class Doctrine_EventListener_Debugger extends Doctrine_EventListener {
class Doctrine_EventListener_Debugger extends Doctrine_EventListener
{
const EVENT_LOAD = 1;
const EVENT_PRELOAD = 2;
......@@ -48,103 +53,131 @@ class Doctrine_EventListener_Debugger extends Doctrine_EventListener {
const EVENT_PRECOLLDELETE = 27;
private $debug;
public function getMessages() {
public function getMessages()
{
return $this->debug;
}
public function onLoad(Doctrine_Record $record) {
public function onLoad(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_LOAD);
}
public function onPreLoad(Doctrine_Record $record) {
public function onPreLoad(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PRELOAD);
}
public function onSleep(Doctrine_Record $record) {
public function onSleep(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_SLEEP);
}
public function onWakeUp(Doctrine_Record $record) {
public function onWakeUp(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_WAKEUP);
}
public function onUpdate(Doctrine_Record $record) {
public function onUpdate(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_UPDATE);
}
public function onPreUpdate(Doctrine_Record $record) {
public function onPreUpdate(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREUPDATE);
}
public function onCreate(Doctrine_Record $record) {
public function onCreate(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_CREATE);
}
public function onPreCreate(Doctrine_Record $record) {
public function onPreCreate(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PRECREATE);
}
public function onSave(Doctrine_Record $record) {
public function onSave(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_SAVE);
}
public function onPreSave(Doctrine_Record $record) {
public function onPreSave(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PRESAVE);
}
public function onInsert(Doctrine_Record $record) {
public function onInsert(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_INSERT);
}
public function onPreInsert(Doctrine_Record $record) {
public function onPreInsert(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREINSERT);
}
public function onDelete(Doctrine_Record $record) {
public function onDelete(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_DELETE);
}
public function onPreDelete(Doctrine_Record $record) {
public function onPreDelete(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREDELETE);
}
public function onEvict(Doctrine_Record $record) {
public function onEvict(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_EVICT);
}
public function onPreEvict(Doctrine_Record $record) {
public function onPreEvict(Doctrine_Record $record)
{
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREEVICT);
}
public function onClose(Doctrine_Connection $connection) {
public function onClose(Doctrine_Connection $connection)
{
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_CLOSE);
}
public function onPreClose(Doctrine_Connection $connection) {
public function onPreClose(Doctrine_Connection $connection)
{
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_PRECLOSE);
}
public function onOpen(Doctrine_Connection $connection) {
public function onOpen(Doctrine_Connection $connection)
{
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_OPEN);
}
public function onTransactionCommit(Doctrine_Connection $connection) {
public function onTransactionCommit(Doctrine_Connection $connection)
{
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_COMMIT);
}
public function onPreTransactionCommit(Doctrine_Connection $connection) {
public function onPreTransactionCommit(Doctrine_Connection $connection)
{
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_PRECOMMIT);
}
public function onTransactionRollback(Doctrine_Connection $connection) {
public function onTransactionRollback(Doctrine_Connection $connection)
{
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_ROLLBACK);
}
public function onPreTransactionRollback(Doctrine_Connection $connection) {
public function onPreTransactionRollback(Doctrine_Connection $connection)
{
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_PREROLLBACK);
}
public function onTransactionBegin(Doctrine_Connection $connection) {
public function onTransactionBegin(Doctrine_Connection $connection)
{
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_BEGIN);
}
public function onPreTransactionBegin(Doctrine_Connection $connection) {
public function onPreTransactionBegin(Doctrine_Connection $connection)
{
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_PREBEGIN);
}
public function onCollectionDelete(Doctrine_Collection $collection) {
public function onCollectionDelete(Doctrine_Collection $collection)
{
$this->debug[] = new Doctrine_DebugMessage($collection,self::EVENT_COLLDELETE);
}
public function onPreCollectionDelete(Doctrine_Collection $collection) {
public function onPreCollectionDelete(Doctrine_Collection $collection)
{
$this->debug[] = new Doctrine_DebugMessage($collection,self::EVENT_PRECOLLDELETE);
}
}
......@@ -9,4 +9,5 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_EventListener_Empty extends Doctrine_EventListener { }
class Doctrine_EventListener_Empty extends Doctrine_EventListener
{ }
......@@ -29,4 +29,5 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Exception extends Exception { }
class Doctrine_Exception extends Exception
{ }
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Module');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Export extends Doctrine_Connection_Module {
class Doctrine_Export extends Doctrine_Connection_Module
{
/**
* drop an existing database
* (this method is implemented by the drivers)
......@@ -39,7 +40,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @param string $name name of the database that should be dropped
* @return void
*/
public function dropDatabase($database) {
public function dropDatabase($database)
{
throw new Doctrine_Export_Exception('Drop database not supported by this driver.');
}
/**
......@@ -50,7 +52,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @throws PDOException
* @return void
*/
public function dropTable($table) {
public function dropTable($table)
{
$this->conn->execute('DROP TABLE ' . $table);
}
......@@ -61,7 +64,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @param string $name name of the index to be dropped
* @return void
*/
public function dropIndex($table, $name) {
public function dropIndex($table, $name)
{
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
return $this->conn->exec('DROP INDEX ' . $name);
}
......@@ -73,7 +77,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @param string $primary hint if the constraint is primary
* @return void
*/
public function dropConstraint($table, $name, $primary = false) {
public function dropConstraint($table, $name, $primary = false)
{
$table = $this->conn->quoteIdentifier($table, true);
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
return $this->conn->exec('ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $name);
......@@ -85,7 +90,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @param string $seq_name name of the sequence to be dropped
* @return void
*/
public function dropSequence($name) {
public function dropSequence($name)
{
throw new Doctrine_Export_Exception('Drop sequence not supported by this driver.');
}
/**
......@@ -95,7 +101,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @param string $name name of the database that should be created
* @return void
*/
public function createDatabase($database) {
public function createDatabase($database)
{
throw new Doctrine_Export_Exception('Create database not supported by this driver.');
}
/**
......@@ -152,7 +159,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @param string $start start value of the sequence; default is 1
* @return void
*/
public function createSequence($seqName, $seqcolName, $start = 1) {
public function createSequence($seqName, $seqcolName, $start = 1)
{
throw new Doctrine_Export_Exception('Create sequence not supported by this driver.');
}
......@@ -177,7 +185,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* )
* @return void
*/
public function createConstraint($table, $name, $definition) {
public function createConstraint($table, $name, $definition)
{
$table = $this->conn->quoteIdentifier($table, true);
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
$query = "ALTER TABLE $table ADD CONSTRAINT $name";
......@@ -225,7 +234,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* )
* @return void
*/
public function createIndex($table, $name, array $definition) {
public function createIndex($table, $name, array $definition)
{
return $this->conn->execute($this->createIndexSql($table, $name, $definition));
}
/**
......@@ -260,7 +270,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* )
* @return string
*/
public function createIndexSql($table, $name, array $definition) {
public function createIndexSql($table, $name, array $definition)
{
$table = $this->conn->quoteIdentifier($table);
$name = $this->conn->quoteIdentifier($name);
......@@ -362,7 +373,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* actually perform them otherwise.
* @return void
*/
public function alterTable($name, array $changes, $check) {
public function alterTable($name, array $changes, $check)
{
$this->conn->execute($this->alterTableSql($name, $changes, $check));
}
/**
......@@ -454,7 +466,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* actually perform them otherwise.
* @return string
*/
public function alterTableSql($name, array $changes, $check) {
public function alterTableSql($name, array $changes, $check)
{
throw new Doctrine_Export_Exception('Alter table not supported by this driver.');
}
/**
......@@ -484,7 +497,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
*
* @return string
*/
public function getFieldDeclarationList(array $fields) {
public function getFieldDeclarationList(array $fields)
{
foreach ($fields as $fieldName => $field) {
$query = $this->getDeclaration($fieldName, $field);
......@@ -519,7 +533,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
*/
public function getDeclaration($name, array $field) {
public function getDeclaration($name, array $field)
{
$default = '';
if (isset($field['default'])) {
......@@ -567,7 +582,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
* of a field declaration.
*/
public function getCharsetFieldDeclaration($charset) {
public function getCharsetFieldDeclaration($charset)
{
return '';
}
/**
......@@ -578,7 +594,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @return string DBMS specific SQL code portion needed to set the COLLATION
* of a field declaration.
*/
public function getCollationFieldDeclaration($collation) {
public function getCollationFieldDeclaration($collation)
{
return '';
}
/**
......@@ -587,7 +604,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
*
* @return void
*/
public static function exportAll() {
public static function exportAll()
{
$parent = new ReflectionClass('Doctrine_Record');
$conn = Doctrine_Manager::getInstance()->getCurrentConnection();
$old = $conn->getAttribute(Doctrine::ATTR_CREATE_TABLES);
......@@ -603,7 +621,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
}
$conn->setAttribute(Doctrine::ATTR_CREATE_TABLES, $old);
}
public function export($record) {
public function export($record)
{
if ( ! $record instanceof Doctrine_Record)
$record = new $record();
......
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Exception extends Doctrine_Exception { }
class Doctrine_Export_Exception extends Doctrine_Exception
{ }
......@@ -32,14 +32,16 @@ Doctrine::autoload('Doctrine_Export');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Export_Firebird extends Doctrine_Export {
class Doctrine_Export_Firebird extends Doctrine_Export
{
/**
* create a new database
*
* @param string $name name of the database that should be created
* @return void
*/
public function createDatabase($name) {
public function createDatabase($name)
{
throw new Doctrine_Export_Firebird_Exception(
'PHP Interbase API does not support direct queries. You have to ' .
'create the db manually by using isql command or a similar program');
......@@ -50,7 +52,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* @param string $name name of the database that should be dropped
* @return void
*/
public function dropDatabase($name) {
public function dropDatabase($name)
{
throw new Doctrine_Export_Firebird_Exception(
'PHP Interbase API does not support direct queries. You have ' .
'to drop the db manually by using isql command or a similar program');
......@@ -63,7 +66,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* @param string $start start value for the sequence
* @return void
*/
public function _makeAutoincrement($name, $table, $start = null) {
public function _makeAutoincrement($name, $table, $start = null)
{
if (is_null($start)) {
$this->conn->beginTransaction();
$query = 'SELECT MAX(' . $this->conn->quoteIdentifier($name, true) . ') FROM ' . $this->conn->quoteIdentifier($table, true);
......@@ -101,7 +105,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* @param string $table name of the table
* @return void
*/
public function _dropAutoincrement($table) {
public function _dropAutoincrement($table)
{
$result = $this->dropSequence($table);
......@@ -180,7 +185,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* @param string $name name of the database that should be dropped
* @return void
*/
public function checkSupportedChanges(&$changes) {
public function checkSupportedChanges(&$changes)
{
foreach ($changes as $change_name => $change) {
switch ($change_name) {
case 'notnull':
......@@ -213,7 +219,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* @return mixed MDB2_OK on success, a MDB2 error on failure
* @access public
*/
public function dropTable($name) {
public function dropTable($name)
{
$result = $this->_dropAutoincrement($name);
$result = parent::dropTable($name);
......@@ -309,7 +316,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* actually perform them otherwise.
* @return void
*/
public function alterTable($name, $changes, $check) {
public function alterTable($name, $changes, $check)
{
foreach ($changes as $change_name => $change) {
switch ($change_name) {
case 'add':
......@@ -416,7 +424,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* )
* @return void
*/
public function createIndex($table, $name, array $definition) {
public function createIndex($table, $name, array $definition)
{
$query = 'CREATE';
$query_sort = '';
......@@ -466,7 +475,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* )
* @return void
*/
public function createConstraint($table, $name, $definition) {
public function createConstraint($table, $name, $definition)
{
$table = $this->conn->quoteIdentifier($table, true);
if (!empty($name)) {
......@@ -500,7 +510,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* @param string $start start value of the sequence; default is 1
* @return void
*/
public function createSequence($seqName, $start = 1) {
public function createSequence($seqName, $start = 1)
{
$sequenceName = $this->conn->getSequenceName($seqName);
$this->conn->exec('CREATE GENERATOR ' . $sequenceName);
......@@ -515,7 +526,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
* @param string $seq_name name of the sequence to be dropped
* @return void
*/
public function dropSequence($seq_name) {
public function dropSequence($seq_name)
{
$sequence_name = $this->conn->getSequenceName($seq_name);
$sequence_name = $this->conn->getDbh()->quote($sequence_name);
$query = "DELETE FROM RDB\$GENERATORS WHERE UPPER(RDB\$GENERATOR_NAME)=$sequence_name";
......
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Export_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Firebird_Exception extends Doctrine_Export_Exception { }
class Doctrine_Export_Firebird_Exception extends Doctrine_Export_Exception
{ }
......@@ -32,14 +32,16 @@ Doctrine::autoload('Doctrine_Export');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Export_Mssql extends Doctrine_Export {
class Doctrine_Export_Mssql extends Doctrine_Export
{
/**
* create a new database
*
* @param string $name name of the database that should be created
* @return void
*/
public function createDatabase($name) {
public function createDatabase($name)
{
$name = $db->quoteIdentifier($name, true);
$query = "CREATE DATABASE $name";
if ($db->options['database_device']) {
......@@ -55,7 +57,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
* @param string $name name of the database that should be dropped
* @return void
*/
public function dropDatabase($name) {
public function dropDatabase($name)
{
$name = $db->quoteIdentifier($name, true);
return $db->standaloneQuery("DROP DATABASE $name", null, true);
}
......@@ -147,7 +150,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
* actually perform them otherwise.
* @return void
*/
public function alterTable($name, $changes, $check) {
public function alterTable($name, $changes, $check)
{
foreach ($changes as $change_name => $change) {
switch ($change_name) {
case 'add':
......@@ -197,7 +201,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
* @param string $start start value of the sequence; default is 1
* @return void
*/
public function createSequence($seq_name, $start = 1) {
public function createSequence($seq_name, $start = 1)
{
$sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
$seqcol_name = $db->quoteIdentifier($db->options['seqcol_name'], true);
$query = "CREATE TABLE $sequence_name ($seqcol_name " .
......@@ -228,7 +233,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
* @param string $seqName name of the sequence to be dropped
* @return void
*/
public function dropSequence($seqName) {
public function dropSequence($seqName)
{
$sequenceName = $db->quoteIdentifier($db->getSequenceName($seqName), true);
return $this->conn->exec('DROP TABLE ' . $sequenceName);
}
......
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Export');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Export_Mysql extends Doctrine_Export {
class Doctrine_Export_Mysql extends Doctrine_Export
{
/**
* create a new database
*
......@@ -39,7 +40,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
* @throws PDOException
* @return void
*/
public function createDatabase($name) {
public function createDatabase($name)
{
$query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true);
$result = $this->conn->exec($query);
}
......@@ -50,7 +52,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
* @throws PDOException
* @access public
*/
public function dropDatabase($name) {
public function dropDatabase($name)
{
$query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
$this->conn->exec($query);
}
......@@ -221,7 +224,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
* actually perform them otherwise.
* @return boolean
*/
public function alterTable($name, array $changes, $check) {
public function alterTable($name, array $changes, $check)
{
if ( ! $name)
throw new Doctrine_Export_Mysql_Exception('no valid table name specified');
......@@ -316,7 +320,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
* @param string $start start value of the sequence; default is 1
* @return boolean
*/
public function createSequence($sequenceName, $seqcol_name, $start = 1) {
public function createSequence($sequenceName, $seqcol_name, $start = 1)
{
$query = 'CREATE TABLE ' . $sequenceName
. ' (' . $seqcol_name . ' INT NOT NULL AUTO_INCREMENT, PRIMARY KEY ('
. $seqcol_name . '))'
......@@ -376,7 +381,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
* @throws PDOException
* @return void
*/
public function createIndex($table, $name, array $definition) {
public function createIndex($table, $name, array $definition)
{
$table = $table;
$name = $this->conn->getIndexName($name);
$query = 'CREATE INDEX ' . $name . ' ON ' . $table;
......@@ -399,7 +405,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
* @param string $name name of the index to be dropped
* @return void
*/
public function dropIndex($table, $name) {
public function dropIndex($table, $name)
{
$table = $this->conn->quoteIdentifier($table, true);
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
return $this->conn->exec('DROP INDEX ' . $name . ' ON ' . $table);
......@@ -411,7 +418,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
* @throws PDOException
* @return void
*/
public function dropTable($table) {
public function dropTable($table)
{
$table = $this->conn->quoteIdentifier($table, true);
$this->conn->exec('DROP TABLE ' . $table);
}
......
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Export_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Mysql_Exception extends Doctrine_Export_Exception { }
class Doctrine_Export_Mysql_Exception extends Doctrine_Export_Exception
{ }
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Export');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Export_Oracle extends Doctrine_Export {
class Doctrine_Export_Oracle extends Doctrine_Export
{
/**
* create a new database
*
......@@ -40,7 +41,7 @@ class Doctrine_Export_Oracle extends Doctrine_Export {
* @return mixed MDB2_OK on success, a MDB2 error on failure
* @access public
*/
public function createDatabase($name)
public function createDatabase($name)
{
if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE))
throw new Doctrine_Export_Oracle_Exception('database creation is only supported if the "emulate_database" attribute is enabled');
......@@ -74,7 +75,7 @@ class Doctrine_Export_Oracle extends Doctrine_Export {
* @return mixed MDB2_OK on success, a MDB2 error on failure
* @access public
*/
public function dropDatabase($name)
public function dropDatabase($name)
{
if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE))
throw new Doctrine_Export_Oracle_Exception('database dropping is only supported if the
......@@ -93,7 +94,7 @@ class Doctrine_Export_Oracle extends Doctrine_Export {
* @return mixed MDB2_OK on success, a MDB2 error on failure
* @access private
*/
public function _makeAutoincrement($name, $table, $start = 1)
public function _makeAutoincrement($name, $table, $start = 1)
{
$table = strtoupper($table);
$index_name = $table . '_AI_PK';
......@@ -163,7 +164,7 @@ END;
* @param string $table name of the table
* @return void
*/
public function dropAutoincrement($table)
public function dropAutoincrement($table)
{
$table = strtoupper($table);
$trigger_name = $table . '_AI_PK';
......@@ -219,7 +220,7 @@ END;
*
* @return void
*/
public function createTable($name, $fields, $options = array())
public function createTable($name, $fields, $options = array())
{
$this->conn->beginTransaction();
......@@ -241,7 +242,7 @@ END;
* @param string $name name of the table that should be dropped
* @return void
*/
public function dropTable($name)
public function dropTable($name)
{
//$this->conn->beginNestedTransaction();
$result = $this->dropAutoincrement($name);
......@@ -337,7 +338,7 @@ END;
* actually perform them otherwise.
* @return void
*/
public function alterTable($name, array $changes, $check)
public function alterTable($name, array $changes, $check)
{
foreach ($changes as $changeName => $change) {
......@@ -420,7 +421,8 @@ END;
* @param string $start start value of the sequence; default is 1
* @return void
*/
public function createSequence($seqName, $start = 1) {
public function createSequence($seqName, $start = 1)
{
$sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true);
$query = 'CREATE SEQUENCE ' . $sequenceName . ' START WITH ' . $start . ' INCREMENT BY 1 NOCACHE';
$query.= ($start < 1 ? ' MINVALUE ' . $start : '');
......@@ -433,7 +435,8 @@ END;
* @param string $seqName name of the sequence to be dropped
* @return void
*/
public function dropSequence($seqName) {
public function dropSequence($seqName)
{
$sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true);
return $this->conn->exec('DROP SEQUENCE ' . $sequenceName);
}
......
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Export');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Export_Pgsql extends Doctrine_Export {
class Doctrine_Export_Pgsql extends Doctrine_Export
{
/**
* create a new database
*
......@@ -39,7 +40,8 @@ class Doctrine_Export_Pgsql extends Doctrine_Export {
* @throws PDOException
* @return void
*/
public function createDatabase($name) {
public function createDatabase($name)
{
$query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name);
$this->conn->exec($query);
}
......@@ -50,7 +52,8 @@ class Doctrine_Export_Pgsql extends Doctrine_Export {
* @throws PDOException
* @access public
*/
public function dropDatabase($name) {
public function dropDatabase($name)
{
$query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
$this->conn->exec($query);
}
......@@ -143,7 +146,8 @@ class Doctrine_Export_Pgsql extends Doctrine_Export {
* @throws PDOException
* @return boolean
*/
public function alterTable($name, $changes, $check) {
public function alterTable($name, $changes, $check)
{
foreach ($changes as $change_name => $change) {
switch ($change_name) {
case 'add':
......
......@@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Export');
* @since 1.0
* @version $Revision$
*/
class Doctrine_Export_Sqlite extends Doctrine_Export {
class Doctrine_Export_Sqlite extends Doctrine_Export
{
/**
* Get the stucture of a field into an array
*
......@@ -64,7 +65,8 @@ class Doctrine_Export_Sqlite extends Doctrine_Export {
* @throws PDOException
* @return void
*/
public function createIndex($table, $name, array $definition) {
public function createIndex($table, $name, array $definition)
{
$table = $this->conn->quoteIdentifier($table, true);
$name = $this->conn->getIndexName($name);
$query = 'CREATE INDEX ' . $name . ' ON ' . $table;
......
This diff is collapsed.
<?php
/*
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
......@@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Exception');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Expression_Exception extends Doctrine_Exception { }
class Doctrine_Expression_Exception extends Doctrine_Exception
{ }
......@@ -32,14 +32,16 @@ Doctrine::autoload('Doctrine_Expression');
* @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver)
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
*/
class Doctrine_Expression_Firebird extends Doctrine_Expression {
class Doctrine_Expression_Firebird extends Doctrine_Expression
{
/**
* return string for internal table used when calling only a function
*
* @return string for internal table used when calling only a function
* @access public
*/
public function functionTable() {
public function functionTable()
{
return ' FROM RDB$DATABASE';
}
/**
......@@ -47,7 +49,8 @@ class Doctrine_Expression_Firebird extends Doctrine_Expression {
*
* @return string define escape pattern
*/
function patternEscapeString() {
function patternEscapeString()
{
return " ESCAPE '". $this->conn->string_quoting['escape_pattern'] ."'";
}
}
......@@ -22,12 +22,13 @@ Doctrine::autoload('Doctrine_Expression');
/**
* Doctrine_Expression_Informix
*
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Expression_Informix extends Doctrine_Expression { }
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Expression_Informix extends Doctrine_Expression
{ }
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Expression');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Expression_Mssql extends Doctrine_Expression {
class Doctrine_Expression_Mssql extends Doctrine_Expression
{
/**
* Return string to call a variable with the current timestamp inside an SQL statement
* There are three special variables for current date and time:
......@@ -41,7 +42,8 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression {
* @return string to call a variable with the current timestamp
* @access public
*/
public function now($type = 'timestamp') {
public function now($type = 'timestamp')
{
switch ($type) {
case 'time':
case 'date':
......@@ -55,7 +57,8 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression {
*
* @return string to call a function to get a substring
*/
public function substring($value, $position, $length = null) {
public function substring($value, $position, $length = null)
{
if (!is_null($length)) {
return "SUBSTRING($value, $position, $length)";
}
......@@ -70,7 +73,8 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression {
* @return string to concatenate two strings
* @access public
**/
function concat($arg1, $arg2) {
function concat($arg1, $arg2)
{
$args = func_get_args();
return '(' . implode(' + ', $args) . ')';
}
......
......@@ -30,13 +30,15 @@ Doctrine::autoload('Doctrine_Expression');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Expression_Mysql extends Doctrine_Expression {
class Doctrine_Expression_Mysql extends Doctrine_Expression
{
/**
* returns the regular expression operator
*
* @return string
*/
public function regexp() {
public function regexp()
{
return 'RLIKE';
}
/**
......@@ -56,7 +58,8 @@ class Doctrine_Expression_Mysql extends Doctrine_Expression {
*
* @return string SQL pattern
*/
public function matchPattern($pattern, $operator = null, $field = null) {
public function matchPattern($pattern, $operator = null, $field = null)
{
$match = '';
if (!is_null($operator)) {
$field = is_null($field) ? '' : $field.' ';
......
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Expression');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Expression_Oracle extends Doctrine_Expression {
class Doctrine_Expression_Oracle extends Doctrine_Expression
{
/**
* Returns a series of strings concatinated
*
......@@ -40,7 +41,8 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression {
* @param string $arg1, $arg2 ... $argN strings that will be concatinated.
* @return string
*/
public function concat($arg1, $arg2) {
public function concat($arg1, $arg2)
{
$args = func_get_args();
$cols = $this->getIdentifiers( $args );
......@@ -56,7 +58,8 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression {
* @param integer $length the substring portion length
* @return string SQL substring function with given parameters
*/
public function substring($value, $position, $length = null) {
public function substring($value, $position, $length = null)
{
if ($length !== null)
return "SUBSTR($value, $position, $length)";
......@@ -71,7 +74,8 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression {
*
* @return string to call a variable with the current timestamp
*/
public function now($type = 'timestamp') {
public function now($type = 'timestamp')
{
switch ($type) {
case 'date':
case 'time':
......@@ -85,7 +89,8 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression {
*
* @return string an oracle SQL string that generates a float between 0 and 1
*/
function random() {
function random()
{
return 'dbms_random.value';
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Hook_Parser');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Hook_Equal extends Doctrine_Hook_Parser {
class Doctrine_Hook_Equal extends Doctrine_Hook_Parser
{
/**
* parse
* Parses given field and field value to DQL condition
......@@ -43,7 +44,8 @@ class Doctrine_Hook_Equal extends Doctrine_Hook_Parser {
* @param mixed $value the value of the field
* @return void
*/
public function parse($alias, $field, $value) {
public function parse($alias, $field, $value)
{
$this->params = (array) $value;
$this->condition = $alias . '.' . $field . ' = ?';
}
......
......@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Hook_Parser_Complex');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Hook_Integer extends Doctrine_Hook_Parser_Complex {
class Doctrine_Hook_Integer extends Doctrine_Hook_Parser_Complex
{
/**
* parse
* Parses given field and field value to DQL condition
......@@ -43,7 +44,8 @@ class Doctrine_Hook_Integer extends Doctrine_Hook_Parser_Complex {
* @param mixed $value the value of the field
* @return void
*/
public function parseSingle($alias, $field, $value) {
public function parseSingle($alias, $field, $value)
{
$e = explode(' ', $value);
foreach ($e as $v) {
......
......@@ -30,15 +30,18 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Hook_Parser {
abstract class Doctrine_Hook_Parser
{
protected $condition;
protected $params = array();
public function getCondition() {
public function getCondition()
{
return $this->condition;
}
public function getParams() {
public function getParams()
{
return $this->params;
}
/**
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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