Commit 4e22f1fb authored by lsmith's avatar lsmith

- second round of PEAR CS fixes

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