- second round of PEAR CS fixes
This commit is contained in:
parent
716bb65b86
commit
4e22f1fbaf
@ -32,7 +32,8 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
final class Doctrine {
|
||||
final class Doctrine
|
||||
{
|
||||
/**
|
||||
* ERROR CONSTANTS
|
||||
*/
|
||||
@ -330,7 +331,8 @@ final class Doctrine {
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
throw new Doctrine_Exception('Doctrine is static class. No instances can be created.');
|
||||
}
|
||||
/**
|
||||
@ -343,7 +345,8 @@ final class Doctrine {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getPath() {
|
||||
public static function getPath()
|
||||
{
|
||||
if (! self::$path) {
|
||||
self::$path = dirname(__FILE__);
|
||||
}
|
||||
@ -355,7 +358,8 @@ final class Doctrine {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function loadAll() {
|
||||
public static function loadAll()
|
||||
{
|
||||
$classes = Doctrine_Compiler::getRuntimeClasses();
|
||||
|
||||
foreach ($classes as $class) {
|
||||
@ -368,7 +372,8 @@ final class Doctrine {
|
||||
*
|
||||
* @param string $directory
|
||||
*/
|
||||
public static function import($directory) {
|
||||
public static function import($directory)
|
||||
{
|
||||
Doctrine_Import::import();
|
||||
}
|
||||
/**
|
||||
@ -377,7 +382,8 @@ final class Doctrine {
|
||||
*
|
||||
* @param string $directory
|
||||
*/
|
||||
public static function export($directory) {
|
||||
public static function export($directory)
|
||||
{
|
||||
Doctrine_Export::export();
|
||||
}
|
||||
/**
|
||||
@ -389,7 +395,8 @@ final class Doctrine {
|
||||
* @throws Doctrine_Exception
|
||||
* @return void
|
||||
*/
|
||||
public static function compile() {
|
||||
public static function compile()
|
||||
{
|
||||
Doctrine_Compiler::compile();
|
||||
}
|
||||
/**
|
||||
@ -399,7 +406,8 @@ final class Doctrine {
|
||||
* @param string $classname
|
||||
* @return boolean
|
||||
*/
|
||||
public static function autoload($classname) {
|
||||
public static function autoload($classname)
|
||||
{
|
||||
if (class_exists($classname)) {
|
||||
return false;
|
||||
}
|
||||
@ -422,7 +430,8 @@ final class Doctrine {
|
||||
* @param string $classname
|
||||
* @return string
|
||||
*/
|
||||
public static function tableize($classname) {
|
||||
public static function tableize($classname)
|
||||
{
|
||||
return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $classname));
|
||||
}
|
||||
/**
|
||||
@ -431,7 +440,8 @@ final class Doctrine {
|
||||
* @param string $tablename
|
||||
* @return string
|
||||
*/
|
||||
public static function classify($tablename) {
|
||||
public static function classify($tablename)
|
||||
{
|
||||
return preg_replace('~(_?)(_)([\w])~e', '"$1".strtoupper("$3")', ucfirst($tablename));
|
||||
}
|
||||
/**
|
||||
@ -440,7 +450,8 @@ final class Doctrine {
|
||||
* @param string $classname
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isValidClassname($classname) {
|
||||
public static function isValidClassname($classname)
|
||||
{
|
||||
if (preg_match('~(^[a-z])|(_[a-z])|([\W])|(_{2})~', $classname))
|
||||
return false;
|
||||
|
||||
|
@ -32,7 +32,8 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
abstract class Doctrine_Access implements ArrayAccess {
|
||||
abstract class Doctrine_Access implements ArrayAccess
|
||||
{
|
||||
/**
|
||||
* setArray
|
||||
*
|
||||
@ -40,7 +41,8 @@ abstract class Doctrine_Access implements ArrayAccess {
|
||||
* @since 1.0
|
||||
* @return Doctrine_Access
|
||||
*/
|
||||
public function setArray(array $array) {
|
||||
public function setArray(array $array)
|
||||
{
|
||||
foreach ($array as $k=>$v) {
|
||||
$this->set($k,$v);
|
||||
};
|
||||
@ -56,7 +58,8 @@ abstract class Doctrine_Access implements ArrayAccess {
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function __set($name,$value) {
|
||||
public function __set($name,$value)
|
||||
{
|
||||
$this->set($name,$value);
|
||||
}
|
||||
/**
|
||||
@ -67,7 +70,8 @@ abstract class Doctrine_Access implements ArrayAccess {
|
||||
* @since 1.0
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name) {
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->get($name);
|
||||
}
|
||||
/**
|
||||
@ -77,7 +81,8 @@ abstract class Doctrine_Access implements ArrayAccess {
|
||||
* @since 1.0
|
||||
* @return boolean whether or not this object contains $name
|
||||
*/
|
||||
public function __isset($name) {
|
||||
public function __isset($name)
|
||||
{
|
||||
return $this->contains($name);
|
||||
}
|
||||
/**
|
||||
@ -87,14 +92,16 @@ abstract class Doctrine_Access implements ArrayAccess {
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($name) {
|
||||
public function __unset($name)
|
||||
{
|
||||
return $this->remove($name);
|
||||
}
|
||||
/**
|
||||
* @param mixed $offset
|
||||
* @return boolean whether or not this object contains $offset
|
||||
*/
|
||||
public function offsetExists($offset) {
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return $this->contains($offset);
|
||||
}
|
||||
/**
|
||||
@ -103,7 +110,8 @@ abstract class Doctrine_Access implements ArrayAccess {
|
||||
* @param mixed $offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset) {
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->get($offset);
|
||||
}
|
||||
/**
|
||||
@ -113,7 +121,8 @@ abstract class Doctrine_Access implements ArrayAccess {
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value) {
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if ( ! isset($offset)) {
|
||||
$this->add($value);
|
||||
} else {
|
||||
@ -125,7 +134,8 @@ abstract class Doctrine_Access implements ArrayAccess {
|
||||
* @see set, offsetSet, __set
|
||||
* @param mixed $offset
|
||||
*/
|
||||
public function offsetUnset($offset) {
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
return $this->remove($offset);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Adapter {
|
||||
class Doctrine_Adapter
|
||||
{
|
||||
const ATTR_AUTOCOMMIT = 0;
|
||||
const ATTR_CASE = 8;
|
||||
const ATTR_CLIENT_VERSION = 5;
|
||||
|
@ -29,22 +29,31 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
abstract class Doctrine_Adapter_Statement {
|
||||
public function bindValue($no, $value) {
|
||||
abstract class Doctrine_Adapter_Statement
|
||||
{
|
||||
public function bindValue($no, $value)
|
||||
{
|
||||
}
|
||||
public function fetch() {
|
||||
public function fetch()
|
||||
{
|
||||
}
|
||||
public function nextRowset() {
|
||||
public function nextRowset()
|
||||
{
|
||||
}
|
||||
public function execute() {
|
||||
public function execute()
|
||||
{
|
||||
}
|
||||
public function errorCode() {
|
||||
public function errorCode()
|
||||
{
|
||||
}
|
||||
public function errorInfo() {
|
||||
public function errorInfo()
|
||||
{
|
||||
}
|
||||
public function rowCount() {
|
||||
public function rowCount()
|
||||
{
|
||||
}
|
||||
public function setFetchMode($mode) {
|
||||
public function setFetchMode($mode)
|
||||
{
|
||||
}
|
||||
public function columnCount(){
|
||||
}
|
||||
|
@ -30,7 +30,8 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Cache_Query_Sqlite implements Countable {
|
||||
class Doctrine_Cache_Query_Sqlite implements Countable
|
||||
{
|
||||
/**
|
||||
* doctrine cache
|
||||
*/
|
||||
@ -48,7 +49,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
|
||||
*
|
||||
* @param Doctrine_Connection|null $connection
|
||||
*/
|
||||
public function __construct($connection = null) {
|
||||
public function __construct($connection = null)
|
||||
{
|
||||
if ( ! ($connection instanceof Doctrine_Connection)) {
|
||||
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
|
||||
}
|
||||
@ -81,7 +83,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
|
||||
* @param integer $lifespan
|
||||
* @return void
|
||||
*/
|
||||
public function store($query, array $result, $lifespan) {
|
||||
public function store($query, array $result, $lifespan)
|
||||
{
|
||||
$sql = "INSERT INTO ".self::CACHE_TABLE." (query_md5, query_result, expires) VALUES (?,?,?)";
|
||||
$stmt = $this->dbh->prepare($sql);
|
||||
$params = array(md5($query), serialize($result), (time() + $lifespan));
|
||||
@ -93,7 +96,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
|
||||
* @param string $md5
|
||||
* @return array
|
||||
*/
|
||||
public function fetch($md5) {
|
||||
public function fetch($md5)
|
||||
{
|
||||
$sql = "SELECT query_result, expires FROM ".self::CACHE_TABLE." WHERE query_md5 = ?";
|
||||
$stmt = $this->dbh->prepare($sql);
|
||||
$params = array($md5);
|
||||
@ -107,7 +111,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function deleteAll() {
|
||||
public function deleteAll()
|
||||
{
|
||||
$sql = "DELETE FROM ".self::CACHE_TABLE;
|
||||
$stmt = $this->dbh->query($sql);
|
||||
return $stmt->rowCount();
|
||||
@ -118,7 +123,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function deleteExpired() {
|
||||
public function deleteExpired()
|
||||
{
|
||||
$sql = "DELETE FROM ".self::CACHE_TABLE." WHERE expired < ?";
|
||||
$stmt = $this->dbh->prepare($sql);
|
||||
$stmt->execute(array(time()));
|
||||
@ -131,7 +137,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
|
||||
* @param string $md5
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete($md5) {
|
||||
public function delete($md5)
|
||||
{
|
||||
$sql = "DELETE FROM ".self::CACHE_TABLE." WHERE query_md5 = ?";
|
||||
$stmt = $this->dbh->prepare($sql);
|
||||
$params = array($md5);
|
||||
@ -143,7 +150,8 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function count() {
|
||||
public function count()
|
||||
{
|
||||
$stmt = $this->dbh->query("SELECT COUNT(*) FROM ".self::CACHE_TABLE);
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload("Doctrine_Access");
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Collection extends Doctrine_Access implements Countable, IteratorAggregate, Serializable {
|
||||
class Doctrine_Collection extends Doctrine_Access implements Countable, IteratorAggregate, Serializable
|
||||
{
|
||||
/**
|
||||
* @var array $data an array containing the data access objects of this collection
|
||||
*/
|
||||
@ -76,7 +77,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @param Doctrine_Table|string $table
|
||||
*/
|
||||
public function __construct($table) {
|
||||
public function __construct($table)
|
||||
{
|
||||
if ( ! ($table instanceof Doctrine_Table)) {
|
||||
$table = Doctrine_Manager::getInstance()
|
||||
->getCurrentConnection()
|
||||
@ -95,7 +97,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function initNullObject(Doctrine_Null $null) {
|
||||
public static function initNullObject(Doctrine_Null $null)
|
||||
{
|
||||
self::$null = $null;
|
||||
}
|
||||
/**
|
||||
@ -104,7 +107,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return Doctrine_Table
|
||||
*/
|
||||
public function getTable() {
|
||||
public function getTable()
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
/**
|
||||
@ -114,7 +118,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setAggregateValue($name, $value) {
|
||||
public function setAggregateValue($name, $value)
|
||||
{
|
||||
$this->aggregateValues[$name] = $value;
|
||||
}
|
||||
/**
|
||||
@ -123,7 +128,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAggregateValue($name) {
|
||||
public function getAggregateValue($name)
|
||||
{
|
||||
return $this->aggregateValues[$name];
|
||||
}
|
||||
/**
|
||||
@ -131,7 +137,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function serialize() {
|
||||
public function serialize()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
|
||||
unset($vars['reference']);
|
||||
@ -151,7 +158,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unserialize($serialized) {
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$manager = Doctrine_Manager::getInstance();
|
||||
$connection = $manager->getCurrentConnection();
|
||||
|
||||
@ -177,7 +185,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* whether or not an offset batch has been expanded
|
||||
* @return boolean
|
||||
*/
|
||||
public function isExpanded($offset) {
|
||||
public function isExpanded($offset)
|
||||
{
|
||||
return isset($this->expanded[$offset]);
|
||||
}
|
||||
/**
|
||||
@ -186,7 +195,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* whether or not this collection is expandable
|
||||
* @return boolean
|
||||
*/
|
||||
public function isExpandable() {
|
||||
public function isExpandable()
|
||||
{
|
||||
return $this->expandable;
|
||||
}
|
||||
/**
|
||||
@ -195,7 +205,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* @param string $column
|
||||
* @return void
|
||||
*/
|
||||
public function setKeyColumn($column) {
|
||||
public function setKeyColumn($column)
|
||||
{
|
||||
$this->keyColumn = $column;
|
||||
}
|
||||
/**
|
||||
@ -204,7 +215,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeyColumn() {
|
||||
public function getKeyColumn()
|
||||
{
|
||||
return $this->column;
|
||||
}
|
||||
/**
|
||||
@ -212,13 +224,15 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData() {
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
public function addData(array $data) {
|
||||
public function addData(array $data)
|
||||
{
|
||||
$this->data[] = $data;
|
||||
}
|
||||
/**
|
||||
@ -227,7 +241,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFirst() {
|
||||
public function getFirst()
|
||||
{
|
||||
return reset($this->data);
|
||||
}
|
||||
/**
|
||||
@ -236,7 +251,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLast() {
|
||||
public function getLast()
|
||||
{
|
||||
return end($this->data);
|
||||
}
|
||||
/**
|
||||
@ -245,7 +261,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setReference(Doctrine_Record $record,Doctrine_Relation $relation) {
|
||||
public function setReference(Doctrine_Record $record,Doctrine_Relation $relation)
|
||||
{
|
||||
$this->reference = $record;
|
||||
$this->relation = $relation;
|
||||
|
||||
@ -273,7 +290,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getReference() {
|
||||
public function getReference()
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
/**
|
||||
@ -282,7 +300,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function expand($key) {
|
||||
public function expand($key)
|
||||
{
|
||||
$where = array();
|
||||
$params = array();
|
||||
$limit = null;
|
||||
@ -402,7 +421,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* @param mixed $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function remove($key) {
|
||||
public function remove($key)
|
||||
{
|
||||
if ( ! isset($this->data[$key])) {
|
||||
$this->expand($key);
|
||||
throw new InvalidKeyException();
|
||||
@ -420,14 +440,16 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* @param mixed $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function contains($key) {
|
||||
public function contains($key)
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
/**
|
||||
* @param mixed $key
|
||||
* @return object Doctrine_Record return a specified record
|
||||
*/
|
||||
public function get($key) {
|
||||
public function get($key)
|
||||
{
|
||||
if ( ! isset($this->data[$key])) {
|
||||
$this->expand($key);
|
||||
|
||||
@ -452,7 +474,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
/**
|
||||
* @return array an array containing all primary keys
|
||||
*/
|
||||
public function getPrimaryKeys() {
|
||||
public function getPrimaryKeys()
|
||||
{
|
||||
$list = array();
|
||||
$name = $this->table->getIdentifier();
|
||||
|
||||
@ -469,7 +492,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* returns all keys
|
||||
* @return array
|
||||
*/
|
||||
public function getKeys() {
|
||||
public function getKeys()
|
||||
{
|
||||
return array_keys($this->data);
|
||||
}
|
||||
/**
|
||||
@ -479,7 +503,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function count() {
|
||||
public function count()
|
||||
{
|
||||
return count($this->data);
|
||||
}
|
||||
/**
|
||||
@ -488,7 +513,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function set($key, Doctrine_Record $record) {
|
||||
public function set($key, Doctrine_Record $record)
|
||||
{
|
||||
if (isset($this->reference_field)) {
|
||||
$record->set($this->reference_field, $this->reference, false);
|
||||
}
|
||||
@ -500,7 +526,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* @param string $key optional key for the record
|
||||
* @return boolean
|
||||
*/
|
||||
public function add(Doctrine_Record $record,$key = null) {
|
||||
public function add(Doctrine_Record $record,$key = null)
|
||||
{
|
||||
if (isset($this->reference_field)) {
|
||||
$record->set($this->reference_field, $this->reference, false);
|
||||
}
|
||||
@ -540,7 +567,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* @param mixed $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function loadRelated($name = null) {
|
||||
public function loadRelated($name = null)
|
||||
{
|
||||
$query = new Doctrine_Query($this->table->getConnection());
|
||||
|
||||
if ( ! isset($name)) {
|
||||
@ -588,7 +616,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* @param Doctrine_Collection $coll
|
||||
* @return void
|
||||
*/
|
||||
public function populateRelated($name, Doctrine_Collection $coll) {
|
||||
public function populateRelated($name, Doctrine_Collection $coll)
|
||||
{
|
||||
$rel = $this->table->getRelation($name);
|
||||
$table = $rel->getTable();
|
||||
$foreign = $rel->getForeign();
|
||||
@ -648,7 +677,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return Doctrine_Iterator_Normal
|
||||
*/
|
||||
public function getNormalIterator() {
|
||||
public function getNormalIterator()
|
||||
{
|
||||
return new Doctrine_Collection_Iterator_Normal($this);
|
||||
}
|
||||
/**
|
||||
@ -657,7 +687,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save(Doctrine_Connection $conn = null) {
|
||||
public function save(Doctrine_Connection $conn = null)
|
||||
{
|
||||
if ($conn == null) {
|
||||
$conn = $this->table->getConnection();
|
||||
}
|
||||
@ -676,7 +707,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(Doctrine_Connection $conn = null) {
|
||||
public function delete(Doctrine_Connection $conn = null)
|
||||
{
|
||||
if ($conn == null) {
|
||||
$conn = $this->table->getConnection();
|
||||
}
|
||||
@ -695,14 +727,16 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* getIterator
|
||||
* @return object ArrayIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator()
|
||||
{
|
||||
$data = $this->data;
|
||||
return new ArrayIterator($data);
|
||||
}
|
||||
/**
|
||||
* returns a string representation of this object
|
||||
*/
|
||||
public function __toString() {
|
||||
public function __toString()
|
||||
{
|
||||
return Doctrine_Lib::getCollectionAsString($this);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ Doctrine::autoload('Doctrine_Collection');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Collection_Batch extends Doctrine_Collection {
|
||||
class Doctrine_Collection_Batch extends Doctrine_Collection
|
||||
{
|
||||
/**
|
||||
* @var integer $batchSize batch size
|
||||
*/
|
||||
@ -42,7 +43,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
|
||||
*/
|
||||
private $loaded = array();
|
||||
|
||||
public function __construct(Doctrine_Table $table) {
|
||||
public function __construct(Doctrine_Table $table)
|
||||
{
|
||||
parent::__construct($table);
|
||||
$this->batchSize = $this->getTable()->getAttribute(Doctrine::ATTR_BATCH_SIZE);
|
||||
}
|
||||
@ -51,7 +53,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
|
||||
* @param integer $batchSize batch size
|
||||
* @return boolean
|
||||
*/
|
||||
public function setBatchSize($batchSize) {
|
||||
public function setBatchSize($batchSize)
|
||||
{
|
||||
$batchSize = (int) $batchSize;
|
||||
if ($batchSize <= 0) {
|
||||
return false;
|
||||
@ -64,7 +67,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBatchSize() {
|
||||
public function getBatchSize()
|
||||
{
|
||||
return $this->batchSize;
|
||||
}
|
||||
/**
|
||||
@ -74,7 +78,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
|
||||
* @param Doctrine_Record $record record to be loaded
|
||||
* @return boolean whether or not the load operation was successful
|
||||
*/
|
||||
public function load(Doctrine_Record $record) {
|
||||
public function load(Doctrine_Record $record)
|
||||
{
|
||||
if (empty($this->data)) {
|
||||
return false;
|
||||
}
|
||||
@ -146,7 +151,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
|
||||
* @param mixed $key the key of the record
|
||||
* @return object Doctrine_Record record
|
||||
*/
|
||||
public function get($key) {
|
||||
public function get($key)
|
||||
{
|
||||
if (isset($this->data[$key])) {
|
||||
switch (gettype($this->data[$key])) {
|
||||
case "array":
|
||||
@ -173,7 +179,8 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
|
||||
/**
|
||||
* @return Doctrine_Iterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator()
|
||||
{
|
||||
return new Doctrine_Collection_Iterator_Expandable($this);
|
||||
}
|
||||
}
|
||||
|
@ -29,4 +29,5 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Collection_Exception extends Doctrine_Exception { }
|
||||
class Doctrine_Collection_Exception extends Doctrine_Exception
|
||||
{ }
|
||||
|
@ -9,12 +9,14 @@ Doctrine::autoload('Doctrine_Collection');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Collection_Immediate extends Doctrine_Collection {
|
||||
class Doctrine_Collection_Immediate extends Doctrine_Collection
|
||||
{
|
||||
/**
|
||||
* @param Doctrine_DQL_Parser $graph
|
||||
* @param integer $key
|
||||
*/
|
||||
public function __construct(Doctrine_Table $table) {
|
||||
public function __construct(Doctrine_Table $table)
|
||||
{
|
||||
parent::__construct($table);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
abstract class Doctrine_Collection_Iterator implements Iterator {
|
||||
abstract class Doctrine_Collection_Iterator implements Iterator
|
||||
{
|
||||
/**
|
||||
* @var Doctrine_Collection $collection
|
||||
*/
|
||||
@ -56,7 +57,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
|
||||
* constructor
|
||||
* @var Doctrine_Collection $collection
|
||||
*/
|
||||
public function __construct(Doctrine_Collection $collection) {
|
||||
public function __construct(Doctrine_Collection $collection)
|
||||
{
|
||||
$this->collection = $collection;
|
||||
$this->keys = $this->collection->getKeys();
|
||||
$this->count = $this->collection->count();
|
||||
@ -66,7 +68,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rewind() {
|
||||
public function rewind()
|
||||
{
|
||||
$this->index = 0;
|
||||
$i = $this->index;
|
||||
if (isset($this->keys[$i])) {
|
||||
@ -79,7 +82,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function key() {
|
||||
public function key()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
/**
|
||||
@ -87,7 +91,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
|
||||
*
|
||||
* @return Doctrine_Record
|
||||
*/
|
||||
public function current() {
|
||||
public function current()
|
||||
{
|
||||
return $this->collection->get($this->key);
|
||||
}
|
||||
/**
|
||||
@ -95,7 +100,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function next() {
|
||||
public function next()
|
||||
{
|
||||
$this->index++;
|
||||
$i = $this->index;
|
||||
if (isset($this->keys[$i])) {
|
||||
|
@ -30,8 +30,10 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterator {
|
||||
public function valid() {
|
||||
class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterator
|
||||
{
|
||||
public function valid()
|
||||
{
|
||||
if ($this->index < $this->count) {
|
||||
return true;
|
||||
} elseif ($this->index == $this->count) {
|
||||
|
@ -30,11 +30,13 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator {
|
||||
class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator
|
||||
{
|
||||
/**
|
||||
* @return boolean whether or not the iteration will continue
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid()
|
||||
{
|
||||
return ($this->index < $this->count);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Collection_Iterator_Offset extends Doctrine_Collection_Iterator {
|
||||
public function valid() { }
|
||||
class Doctrine_Collection_Iterator_Offset extends Doctrine_Collection_Iterator
|
||||
{
|
||||
public function valid()
|
||||
{ }
|
||||
}
|
||||
|
@ -11,13 +11,15 @@ require_once("Batch.php");
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Collection_Lazy extends Doctrine_Collection_Batch {
|
||||
class Doctrine_Collection_Lazy extends Doctrine_Collection_Batch
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
* @param Doctrine_DQL_Parser $graph
|
||||
* @param string $key
|
||||
*/
|
||||
public function __construct(Doctrine_Table $table) {
|
||||
public function __construct(Doctrine_Table $table)
|
||||
{
|
||||
parent::__construct($table);
|
||||
parent::setBatchSize(1);
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Collection_Offset');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Collection_Offset extends Doctrine_Collection {
|
||||
class Doctrine_Collection_Offset extends Doctrine_Collection
|
||||
{
|
||||
/**
|
||||
* @var integer $limit
|
||||
*/
|
||||
@ -39,20 +40,23 @@ class Doctrine_Collection_Offset extends Doctrine_Collection {
|
||||
/**
|
||||
* @param Doctrine_Table $table
|
||||
*/
|
||||
public function __construct(Doctrine_Table $table) {
|
||||
public function __construct(Doctrine_Table $table)
|
||||
{
|
||||
parent::__construct($table);
|
||||
$this->limit = $table->getAttribute(Doctrine::ATTR_COLL_LIMIT);
|
||||
}
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getLimit() {
|
||||
public function getLimit()
|
||||
{
|
||||
return $this->limit;
|
||||
}
|
||||
/**
|
||||
* @return Doctrine_Collection_Iterator_Expandable
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator()
|
||||
{
|
||||
return new Doctrine_Collection_Iterator_Expandable($this);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Compiler {
|
||||
class Doctrine_Compiler
|
||||
{
|
||||
/**
|
||||
* @var array $classes an array containing all runtime classes of Doctrine framework
|
||||
*/
|
||||
@ -109,7 +110,8 @@ class Doctrine_Compiler {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRuntimeClasses() {
|
||||
public static function getRuntimeClasses()
|
||||
{
|
||||
return self::$classes;
|
||||
}
|
||||
/**
|
||||
@ -120,7 +122,8 @@ class Doctrine_Compiler {
|
||||
* @throws Doctrine_Compiler_Exception if something went wrong during the compile operation
|
||||
* @return void
|
||||
*/
|
||||
public static function compile($target = null) {
|
||||
public static function compile($target = null)
|
||||
{
|
||||
$path = Doctrine::getPath();
|
||||
|
||||
$classes = self::$classes;
|
||||
|
@ -29,4 +29,5 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Compiler_Exception extends Doctrine_Exception { }
|
||||
class Doctrine_Compiler_Exception extends Doctrine_Exception
|
||||
{ }
|
||||
|
@ -31,7 +31,8 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
abstract class Doctrine_Configurable {
|
||||
abstract class Doctrine_Configurable
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array $attributes an array of containing all attributes
|
||||
@ -60,7 +61,8 @@ abstract class Doctrine_Configurable {
|
||||
* @throws Doctrine_Exception if the value is invalid
|
||||
* @return void
|
||||
*/
|
||||
public function setAttribute($attribute,$value) {
|
||||
public function setAttribute($attribute,$value)
|
||||
{
|
||||
switch ($attribute) {
|
||||
case Doctrine::ATTR_BATCH_SIZE:
|
||||
if ($value < 0) {
|
||||
@ -153,7 +155,8 @@ abstract class Doctrine_Configurable {
|
||||
* @param Doctrine_EventListener $listener
|
||||
* @return void
|
||||
*/
|
||||
public function setEventListener($listener) {
|
||||
public function setEventListener($listener)
|
||||
{
|
||||
return $this->setListener($listener);
|
||||
}
|
||||
/**
|
||||
@ -162,7 +165,8 @@ abstract class Doctrine_Configurable {
|
||||
* @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener
|
||||
* @return Doctrine_Db
|
||||
*/
|
||||
public function addListener($listener, $name = null) {
|
||||
public function addListener($listener, $name = null)
|
||||
{
|
||||
if ( ! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) {
|
||||
$this->attributes[Doctrine::ATTR_LISTENER] = new Doctrine_EventListener_Chain();
|
||||
}
|
||||
@ -175,7 +179,8 @@ abstract class Doctrine_Configurable {
|
||||
*
|
||||
* @return Doctrine_Db_EventListener_Interface|Doctrine_Overloadable
|
||||
*/
|
||||
public function getListener() {
|
||||
public function getListener()
|
||||
{
|
||||
if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER])) {
|
||||
if (isset($this->parent)) {
|
||||
return $this->parent->getListener();
|
||||
@ -190,7 +195,8 @@ abstract class Doctrine_Configurable {
|
||||
* @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener
|
||||
* @return Doctrine_Db
|
||||
*/
|
||||
public function setListener($listener) {
|
||||
public function setListener($listener)
|
||||
{
|
||||
if ( ! ($listener instanceof Doctrine_EventListener_Interface)
|
||||
&& ! ($listener instanceof Doctrine_Overloadable)
|
||||
) {
|
||||
@ -206,7 +212,8 @@ abstract class Doctrine_Configurable {
|
||||
* @param integer $attribute
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttribute($attribute) {
|
||||
public function getAttribute($attribute)
|
||||
{
|
||||
$attribute = (int) $attribute;
|
||||
|
||||
if ($attribute < 1 || $attribute > 23)
|
||||
@ -226,7 +233,8 @@ abstract class Doctrine_Configurable {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes() {
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
/**
|
||||
@ -236,7 +244,8 @@ abstract class Doctrine_Configurable {
|
||||
* @param Doctrine_Configurable $component
|
||||
* @return void
|
||||
*/
|
||||
public function setParent(Doctrine_Configurable $component) {
|
||||
public function setParent(Doctrine_Configurable $component)
|
||||
{
|
||||
$this->parent = $component;
|
||||
}
|
||||
/**
|
||||
@ -245,7 +254,8 @@ abstract class Doctrine_Configurable {
|
||||
*
|
||||
* @return Doctrine_Configurable
|
||||
*/
|
||||
public function getParent() {
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
* @author Lukas Smith <smith@pooteeweet.org> (MDB2 library)
|
||||
*/
|
||||
abstract class Doctrine_Connection extends Doctrine_Configurable implements Countable, IteratorAggregate {
|
||||
abstract class Doctrine_Connection extends Doctrine_Configurable implements Countable, IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* @var $dbh the database handler
|
||||
*/
|
||||
@ -109,7 +110,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param Doctrine_Manager $manager the manager object
|
||||
* @param PDO|Doctrine_Adapter_Interface $adapter database driver
|
||||
*/
|
||||
public function __construct(Doctrine_Manager $manager, $adapter) {
|
||||
public function __construct(Doctrine_Manager $manager, $adapter)
|
||||
{
|
||||
if ( ! ($adapter instanceof PDO) && ! in_array('Doctrine_Adapter_Interface', class_implements($adapter))) {
|
||||
throw new Doctrine_Connection_Exception("First argument should be an instance of PDO or implement Doctrine_Adapter_Interface");
|
||||
}
|
||||
@ -131,7 +133,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return string the name of this driver
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName()
|
||||
{
|
||||
return $this->driverName;
|
||||
}
|
||||
/**
|
||||
@ -147,7 +150,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @throws Doctrine_Connection_Exception if trying to get an unknown module
|
||||
* @return Doctrine_Connection_Module connection module
|
||||
*/
|
||||
public function __get($name) {
|
||||
public function __get($name)
|
||||
{
|
||||
if (isset($this->properties[$name]))
|
||||
return $this->properties[$name];
|
||||
|
||||
@ -179,7 +183,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return string quoted string
|
||||
*/
|
||||
public function escapePattern($text) {
|
||||
public function escapePattern($text)
|
||||
{
|
||||
if ($this->string_quoting['escape_pattern']) {
|
||||
$text = str_replace($this->string_quoting['escape_pattern'], $this->string_quoting['escape_pattern'] . $this->string_quoting['escape_pattern'], $text);
|
||||
foreach ($this->wildcards as $wildcard) {
|
||||
@ -220,7 +225,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return string quoted identifier string
|
||||
*/
|
||||
public function quoteIdentifier($str, $checkOption = true) {
|
||||
public function quoteIdentifier($str, $checkOption = true)
|
||||
{
|
||||
if ($checkOption && ! $this->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) {
|
||||
return $str;
|
||||
}
|
||||
@ -236,7 +242,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return Doctrine_Manager
|
||||
*/
|
||||
public function getManager() {
|
||||
public function getManager()
|
||||
{
|
||||
return $this->getParent();
|
||||
}
|
||||
/**
|
||||
@ -244,7 +251,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return PDO the database handler
|
||||
*/
|
||||
public function getDbh() {
|
||||
public function getDbh()
|
||||
{
|
||||
return $this->dbh;
|
||||
}
|
||||
/**
|
||||
@ -252,7 +260,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public function driverName($name) {
|
||||
public function driverName($name)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* supports
|
||||
@ -260,7 +269,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param string $feature the name of the feature
|
||||
* @return boolean whether or not this drivers supports given feature
|
||||
*/
|
||||
public function supports($feature) {
|
||||
public function supports($feature)
|
||||
{
|
||||
return (isset($this->supported[$feature])
|
||||
&& ($this->supported[$feature] === 'emulated'
|
||||
|| $this->supported[$feature]
|
||||
@ -275,7 +285,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
public function quote($input, $type = null) {
|
||||
public function quote($input, $type = null)
|
||||
{
|
||||
if ($type == null) {
|
||||
$type = gettype($input);
|
||||
}
|
||||
@ -303,7 +314,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param string $sqn string that containts name of a potential sequence
|
||||
* @return string name of the sequence with possible formatting removed
|
||||
*/
|
||||
public function fixSequenceName($sqn) {
|
||||
public function fixSequenceName($sqn)
|
||||
{
|
||||
$seqPattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $this->getAttribute(Doctrine::ATTR_SEQNAME_FORMAT)).'$/i';
|
||||
$seqName = preg_replace($seqPattern, '\\1', $sqn);
|
||||
|
||||
@ -318,7 +330,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param string $idx string that containts name of anl index
|
||||
* @return string name of the index with possible formatting removed
|
||||
*/
|
||||
public function fixIndexName($idx) {
|
||||
public function fixIndexName($idx)
|
||||
{
|
||||
$indexPattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $this->getAttribute(Doctrine::ATTR_IDXNAME_FORMAT)).'$/i';
|
||||
$indexName = preg_replace($indexPattern, '\\1', $idx);
|
||||
if ($indexName && ! strcasecmp($idx, $this->getIndexName($indexName))) {
|
||||
@ -332,7 +345,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param string name of the sequence
|
||||
* @return string formatted sequence name
|
||||
*/
|
||||
public function getSequenceName($sqn) {
|
||||
public function getSequenceName($sqn)
|
||||
{
|
||||
return sprintf($this->getAttribute(Doctrine::ATTR_SEQNAME_FORMAT),
|
||||
preg_replace('/[^a-z0-9_\$.]/i', '_', $sqn));
|
||||
}
|
||||
@ -342,7 +356,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param string name of the index
|
||||
* @return string formatted index name
|
||||
*/
|
||||
public function getIndexName($idx) {
|
||||
public function getIndexName($idx)
|
||||
{
|
||||
return sprintf($this->getAttribute(Doctrine::ATTR_IDXNAME_FORMAT),
|
||||
preg_replace('/[^a-z0-9_\$]/i', '_', $idx));
|
||||
}
|
||||
@ -381,7 +396,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @throws PDOException if something fails at PDO level
|
||||
* @return integer number of rows affected
|
||||
*/
|
||||
public function replace($table, array $fields, array $keys) {
|
||||
public function replace($table, array $fields, array $keys)
|
||||
{
|
||||
//if ( ! $this->supports('replace'))
|
||||
// throw new Doctrine_Connection_Exception('replace query is not supported');
|
||||
|
||||
@ -444,7 +460,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @throws PDOException if something went wrong at database level
|
||||
* @return integer
|
||||
*/
|
||||
public function nextId($sequence) {
|
||||
public function nextId($sequence)
|
||||
{
|
||||
throw new Doctrine_Connection_Exception('NextId() for sequences not supported by this driver.');
|
||||
}
|
||||
/**
|
||||
@ -454,7 +471,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCharset($charset) {
|
||||
public function setCharset($charset)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* fetchAll
|
||||
@ -589,7 +607,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param integer $offset
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public function select($query,$limit = 0,$offset = 0) {
|
||||
public function select($query,$limit = 0,$offset = 0)
|
||||
{
|
||||
if ($limit > 0 || $offset > 0) {
|
||||
$query = $this->modifyLimitQuery($query, $limit, $offset);
|
||||
}
|
||||
@ -642,7 +661,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @throws Doctrine_Connection_Exception
|
||||
*/
|
||||
private function rethrowException(Exception $e) {
|
||||
private function rethrowException(Exception $e)
|
||||
{
|
||||
$name = 'Doctrine_Connection_' . $this->driverName . '_Exception';
|
||||
|
||||
$exc = new $name($e->getMessage(), (int) $e->getCode());
|
||||
@ -660,7 +680,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param mixed $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasTable($name) {
|
||||
public function hasTable($name)
|
||||
{
|
||||
return isset($this->tables[$name]);
|
||||
}
|
||||
/**
|
||||
@ -669,7 +690,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param string $name component name
|
||||
* @return object Doctrine_Table
|
||||
*/
|
||||
public function getTable($name) {
|
||||
public function getTable($name)
|
||||
{
|
||||
if (isset($this->tables[$name])) {
|
||||
return $this->tables[$name];
|
||||
}
|
||||
@ -686,7 +708,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTables() {
|
||||
public function getTables()
|
||||
{
|
||||
return $this->tables;
|
||||
}
|
||||
/**
|
||||
@ -701,7 +724,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return ArrayIterator SPL ArrayIterator object
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->tables);
|
||||
}
|
||||
/**
|
||||
@ -709,7 +733,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function count() {
|
||||
public function count()
|
||||
{
|
||||
return count($this->tables);
|
||||
}
|
||||
/**
|
||||
@ -719,7 +744,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param $objTable a Doctrine_Table object to be added into registry
|
||||
* @return boolean
|
||||
*/
|
||||
public function addTable(Doctrine_Table $objTable) {
|
||||
public function addTable(Doctrine_Table $objTable)
|
||||
{
|
||||
$name = $objTable->getComponentName();
|
||||
|
||||
if (isset($this->tables[$name])) {
|
||||
@ -736,7 +762,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param string $name component name
|
||||
* @return Doctrine_Record Doctrine_Record object
|
||||
*/
|
||||
public function create($name) {
|
||||
public function create($name)
|
||||
{
|
||||
return $this->getTable($name)->create();
|
||||
}
|
||||
/**
|
||||
@ -747,7 +774,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @throws PDOException if something went wrong at database level
|
||||
* @return void
|
||||
*/
|
||||
public function flush() {
|
||||
public function flush()
|
||||
{
|
||||
$this->beginTransaction();
|
||||
$this->unitOfWork->saveAll();
|
||||
$this->commit();
|
||||
@ -758,7 +786,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear() {
|
||||
public function clear()
|
||||
{
|
||||
foreach ($this->tables as $k => $table) {
|
||||
$table->getRepository()->evictAll();
|
||||
$table->clear();
|
||||
@ -770,7 +799,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function evictTables() {
|
||||
public function evictTables()
|
||||
{
|
||||
$this->tables = array();
|
||||
}
|
||||
/**
|
||||
@ -779,7 +809,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function close() {
|
||||
public function close()
|
||||
{
|
||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->onPreClose($this);
|
||||
|
||||
$this->clear();
|
||||
@ -791,7 +822,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getTransactionLevel() {
|
||||
public function getTransactionLevel()
|
||||
{
|
||||
return $this->transaction->getTransactionLevel();
|
||||
}
|
||||
/**
|
||||
@ -803,7 +835,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function beginTransaction() {
|
||||
public function beginTransaction()
|
||||
{
|
||||
$this->transaction->beginTransaction();
|
||||
}
|
||||
/**
|
||||
@ -813,7 +846,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function commit() {
|
||||
public function commit()
|
||||
{
|
||||
$this->transaction->commit();
|
||||
}
|
||||
/**
|
||||
@ -825,7 +859,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rollback() {
|
||||
public function rollback()
|
||||
{
|
||||
$this->transaction->rollback();
|
||||
}
|
||||
/**
|
||||
@ -834,7 +869,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function save(Doctrine_Record $record) {
|
||||
public function save(Doctrine_Record $record)
|
||||
{
|
||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreSave($record);
|
||||
|
||||
switch ($record->getState()) {
|
||||
@ -861,7 +897,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
public function delete(Doctrine_Record $record) {
|
||||
public function delete(Doctrine_Record $record)
|
||||
{
|
||||
if ( ! $record->exists()) {
|
||||
return false;
|
||||
}
|
||||
@ -883,7 +920,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* returns a string representation of this object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
public function __toString()
|
||||
{
|
||||
return Doctrine_Lib::getConnectionAsString($this);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ Doctrine::autoload('Doctrine_Connection');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Connection_Common extends Doctrine_Connection {
|
||||
class Doctrine_Connection_Common extends Doctrine_Connection
|
||||
{
|
||||
/**
|
||||
* Adds an driver-specific LIMIT clause to the query
|
||||
*
|
||||
@ -18,7 +19,8 @@ class Doctrine_Connection_Common extends Doctrine_Connection {
|
||||
* @param mixed $limit
|
||||
* @param mixed $offset
|
||||
*/
|
||||
public function modifyLimitQuery($query,$limit = false,$offset = false,$isManip=false) {
|
||||
public function modifyLimitQuery($query,$limit = false,$offset = false,$isManip=false)
|
||||
{
|
||||
if ($limit && $offset) {
|
||||
$query .= " LIMIT ".$limit." OFFSET ".$offset;
|
||||
} elseif ($limit && ! $offset) {
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Connection');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Connection_Db2 extends Doctrine_Connection {
|
||||
class Doctrine_Connection_Db2 extends Doctrine_Connection
|
||||
{
|
||||
/**
|
||||
* Adds an driver-specific LIMIT clause to the query
|
||||
*
|
||||
@ -39,7 +40,8 @@ class Doctrine_Connection_Db2 extends Doctrine_Connection {
|
||||
* @param integer $offset start reading from given offset
|
||||
* @return string the modified query
|
||||
*/
|
||||
public function modifyLimitQuery($query, $limit, $offset) {
|
||||
public function modifyLimitQuery($query, $limit, $offset)
|
||||
{
|
||||
if ($limit <= 0)
|
||||
return $sql;
|
||||
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Connection_Exception extends Doctrine_Exception {
|
||||
class Doctrine_Connection_Exception extends Doctrine_Exception
|
||||
{
|
||||
/**
|
||||
* @var array $errorMessages an array containing messages for portable error codes
|
||||
*/
|
||||
@ -80,7 +81,8 @@ class Doctrine_Connection_Exception extends Doctrine_Exception {
|
||||
*
|
||||
* @return integer portable error code
|
||||
*/
|
||||
public function getPortableCode() {
|
||||
public function getPortableCode()
|
||||
{
|
||||
return $this->portableCode;
|
||||
}
|
||||
/**
|
||||
@ -89,7 +91,8 @@ class Doctrine_Connection_Exception extends Doctrine_Exception {
|
||||
*
|
||||
* @return string portable error message
|
||||
*/
|
||||
public function getPortableMessage() {
|
||||
public function getPortableMessage()
|
||||
{
|
||||
return self::errorMessage($this->portableCode);
|
||||
}
|
||||
/**
|
||||
@ -102,7 +105,8 @@ class Doctrine_Connection_Exception extends Doctrine_Exception {
|
||||
* @return string error message, or false if the error code was
|
||||
* not recognized
|
||||
*/
|
||||
public static function errorMessage($value = null) {
|
||||
public static function errorMessage($value = null)
|
||||
{
|
||||
return isset(self::$errorMessages[$value]) ?
|
||||
self::$errorMessages[$value] : self::$errorMessages[Doctrine::ERR];
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ Doctrine::autoload('Doctrine_Connection');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Connection_Firebird extends Doctrine_Connection {
|
||||
class Doctrine_Connection_Firebird extends Doctrine_Connection
|
||||
{
|
||||
/**
|
||||
* @var string $driverName the name of this connection driver
|
||||
*/
|
||||
@ -43,7 +44,8 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
|
||||
* @param Doctrine_Manager $manager
|
||||
* @param PDO $pdo database handle
|
||||
*/
|
||||
public function __construct(Doctrine_Manager $manager, $adapter) {
|
||||
public function __construct(Doctrine_Manager $manager, $adapter)
|
||||
{
|
||||
|
||||
$this->supported = array(
|
||||
'sequences' => true,
|
||||
@ -82,7 +84,8 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCharset($charset) {
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$query = 'SET NAMES '.$this->dbh->quote($charset);
|
||||
$this->dbh->query($query);
|
||||
}
|
||||
@ -94,7 +97,8 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
|
||||
* @param integer $offset start reading from given offset
|
||||
* @return string modified query
|
||||
*/
|
||||
public function modifyLimitQuery($query, $limit, $offset) {
|
||||
public function modifyLimitQuery($query, $limit, $offset)
|
||||
{
|
||||
if ($limit > 0) {
|
||||
$query = preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i',
|
||||
"SELECT FIRST $limit SKIP $offset", $query);
|
||||
@ -106,7 +110,8 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
|
||||
* @param string $sequence
|
||||
* @return integer
|
||||
*/
|
||||
public function getNextID($sequence) {
|
||||
public function getNextID($sequence)
|
||||
{
|
||||
$stmt = $this->query('SELECT UNIQUE FROM ' . $sequence);
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
|
@ -32,7 +32,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
|
||||
* @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver)
|
||||
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
|
||||
*/
|
||||
class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Exception {
|
||||
class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Exception
|
||||
{
|
||||
/**
|
||||
* @var array $errorCodeMap an array that is used for determining portable
|
||||
* error code from a native database error code
|
||||
@ -106,7 +107,8 @@ class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Excepti
|
||||
* @since 1.0
|
||||
* @return array
|
||||
*/
|
||||
public function processErrorInfo(array $errorInfo) {
|
||||
public function processErrorInfo(array $errorInfo)
|
||||
{
|
||||
/**
|
||||
// todo: are the following lines needed?
|
||||
// memo for the interbase php module hackers: we need something similar
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Connection');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Connection_Informix extends Doctrine_Connection {
|
||||
class Doctrine_Connection_Informix extends Doctrine_Connection
|
||||
{
|
||||
/**
|
||||
* @var string $driverName the name of this connection driver
|
||||
*/
|
||||
@ -41,7 +42,8 @@ class Doctrine_Connection_Informix extends Doctrine_Connection {
|
||||
* @param Doctrine_Manager $manager
|
||||
* @param PDO $pdo database handle
|
||||
*/
|
||||
public function __construct(Doctrine_Manager $manager, $adapter) {
|
||||
public function __construct(Doctrine_Manager $manager, $adapter)
|
||||
{
|
||||
// initialize all driver options
|
||||
|
||||
parent::__construct($manager, $adapter);
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Connection_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Connection_Informix_Exception extends Doctrine_Connection_Exception { }
|
||||
class Doctrine_Connection_Informix_Exception extends Doctrine_Connection_Exception
|
||||
{ }
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Common');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Connection_Mock extends Doctrine_Connection_Common {
|
||||
class Doctrine_Connection_Mock extends Doctrine_Connection_Common
|
||||
{
|
||||
/**
|
||||
* @var string $driverName the name of this connection driver
|
||||
*/
|
||||
@ -42,7 +43,8 @@ class Doctrine_Connection_Mock extends Doctrine_Connection_Common {
|
||||
* @param Doctrine_Manager $manager
|
||||
* @param PDO|Doctrine_Adapter $adapter database handler
|
||||
*/
|
||||
public function __construct(Doctrine_Manager $manager, $adapter) {
|
||||
public function __construct(Doctrine_Manager $manager, $adapter)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,8 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Connection_Module {
|
||||
class Doctrine_Connection_Module
|
||||
{
|
||||
/**
|
||||
* @var Doctrine_Connection $conn Doctrine_Connection object, every connection
|
||||
* module holds an instance of Doctrine_Connection
|
||||
@ -43,7 +44,8 @@ class Doctrine_Connection_Module {
|
||||
* @param Doctrine_Connection $conn Doctrine_Connection object, every connection
|
||||
* module holds an instance of Doctrine_Connection
|
||||
*/
|
||||
public function __construct($conn = null) {
|
||||
public function __construct($conn = null)
|
||||
{
|
||||
if ( ! ($conn instanceof Doctrine_Connection)) {
|
||||
$conn = Doctrine_Manager::getInstance()->getCurrentConnection();
|
||||
}
|
||||
@ -59,7 +61,8 @@ class Doctrine_Connection_Module {
|
||||
*
|
||||
* @return Doctrine_Connection
|
||||
*/
|
||||
public function getConnection() {
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->conn;
|
||||
}
|
||||
/**
|
||||
@ -68,7 +71,8 @@ class Doctrine_Connection_Module {
|
||||
*
|
||||
* @return string the name of this module
|
||||
*/
|
||||
public function getModuleName() {
|
||||
public function getModuleName()
|
||||
{
|
||||
return $this->moduleName;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
class Doctrine_Connection_Mssql extends Doctrine_Connection
|
||||
{
|
||||
/**
|
||||
* @var string $driverName the name of this connection driver
|
||||
*/
|
||||
@ -42,7 +43,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
* @param Doctrine_Manager $manager
|
||||
* @param PDO $pdo database handle
|
||||
*/
|
||||
public function __construct(Doctrine_Manager $manager, $adapter) {
|
||||
public function __construct(Doctrine_Manager $manager, $adapter)
|
||||
{
|
||||
// initialize all driver options
|
||||
$this->supported = array(
|
||||
'sequences' => 'emulated',
|
||||
@ -75,7 +77,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
*
|
||||
* @return string quoted identifier string
|
||||
*/
|
||||
public function quoteIdentifier($identifier, $checkOption = false) {
|
||||
public function quoteIdentifier($identifier, $checkOption = false)
|
||||
{
|
||||
if ($checkOption && ! $this->options['quote_identifier']) {
|
||||
return $identifier;
|
||||
}
|
||||
@ -87,7 +90,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
* @param string $sequence name of the sequence
|
||||
* @return integer the next value in the given sequence
|
||||
*/
|
||||
public function nextId($sequence) {
|
||||
public function nextId($sequence)
|
||||
{
|
||||
$this->query("INSERT INTO $sequence (vapor) VALUES (0)");
|
||||
$stmt = $this->query("SELECT @@IDENTITY FROM $sequence");
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
@ -103,7 +107,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
* @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
|
||||
* @return string
|
||||
*/
|
||||
public function modifyLimitQuery($query, $limit, $offset, $isManip = false) {
|
||||
public function modifyLimitQuery($query, $limit, $offset, $isManip = false)
|
||||
{
|
||||
if ($limit > 0) {
|
||||
// we need the starting SELECT clause for later
|
||||
$select = 'SELECT ';
|
||||
@ -154,7 +159,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
* @param string $field name of the field into which a new row was inserted
|
||||
* @return integer
|
||||
*/
|
||||
public function lastInsertID($table = null, $field = null) {
|
||||
public function lastInsertID($table = null, $field = null)
|
||||
{
|
||||
$server_info = $this->getServerVersion();
|
||||
if (is_array($server_info)
|
||||
&& !is_null($server_info['major'])
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
|
||||
* @category Object Relational Mapping
|
||||
* @link www.phpdoctrine.com
|
||||
*/
|
||||
class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception {
|
||||
class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception
|
||||
{
|
||||
/**
|
||||
* @var array $errorCodeMap an array that is used for determining portable
|
||||
* error code from a native database error code
|
||||
@ -61,7 +62,8 @@ class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception
|
||||
* @return boolean whether or not the error info processing was successfull
|
||||
* (the process is successfull if portable error code was found)
|
||||
*/
|
||||
public function processErrorInfo(array $errorInfo) {
|
||||
public function processErrorInfo(array $errorInfo)
|
||||
{
|
||||
$code = $errorInfo[1];
|
||||
if (isset(self::$errorCodeMap[$code])) {
|
||||
$this->portableCode = self::$errorCodeMap[$code];
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Common');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
|
||||
class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
|
||||
{
|
||||
/**
|
||||
* @var string $driverName the name of this connection driver
|
||||
*/
|
||||
@ -42,7 +43,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
|
||||
* @param Doctrine_Manager $manager
|
||||
* @param PDO|Doctrine_Adapter $adapter database handler
|
||||
*/
|
||||
public function __construct(Doctrine_Manager $manager, $adapter) {
|
||||
public function __construct(Doctrine_Manager $manager, $adapter)
|
||||
{
|
||||
$adapter->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
|
||||
|
||||
$this->setAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE, 'INNODB');
|
||||
@ -94,7 +96,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCharset($charset) {
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$query = 'SET NAMES '.$this->dbh->quote($charset);
|
||||
$this->dbh->query($query);
|
||||
}
|
||||
@ -110,7 +113,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function nextId($seqName, $ondemand = true) {
|
||||
public function nextId($seqName, $ondemand = true)
|
||||
{
|
||||
$sequenceName = $this->quoteIdentifier($this->getSequenceName($seqName), true);
|
||||
$seqcolName = $this->quoteIdentifier($this->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true);
|
||||
$query = 'INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES (NULL)';
|
||||
@ -129,7 +133,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
|
||||
* @param string $seq_name name of the sequence
|
||||
* @return integer
|
||||
*/
|
||||
public function currId($seqName) {
|
||||
public function currId($seqName)
|
||||
{
|
||||
$sequenceName = $this->quoteIdentifier($this->getSequenceName($seqName), true);
|
||||
$seqcolName = $this->quoteIdentifier($this->options['seqcol_name'], true);
|
||||
$query = 'SELECT MAX(' . $seqcolName . ') FROM ' . $sequenceName;
|
||||
@ -199,7 +204,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
|
||||
*
|
||||
* @return integer the number of affected rows
|
||||
*/
|
||||
public function replace($table, array $fields, array $keys) {
|
||||
public function replace($table, array $fields, array $keys)
|
||||
{
|
||||
$count = count($fields);
|
||||
$query = $values = '';
|
||||
$keys = $colnum = 0;
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
|
||||
* @category Object Relational Mapping
|
||||
* @link www.phpdoctrine.com
|
||||
*/
|
||||
class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception {
|
||||
class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception
|
||||
{
|
||||
/**
|
||||
* @var array $errorCodeMap an array that is used for determining portable
|
||||
* error code from a native database error code
|
||||
@ -71,7 +72,8 @@ class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception
|
||||
* @return boolean whether or not the error info processing was successfull
|
||||
* (the process is successfull if portable error code was found)
|
||||
*/
|
||||
public function processErrorInfo(array $errorInfo) {
|
||||
public function processErrorInfo(array $errorInfo)
|
||||
{
|
||||
$code = $errorInfo[1];
|
||||
if (isset(self::$errorCodeMap[$code])) {
|
||||
$this->portableCode = self::$errorCodeMap[$code];
|
||||
|
@ -30,13 +30,15 @@ Doctrine::autoload('Doctrine_Connection');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Connection_Oracle extends Doctrine_Connection {
|
||||
class Doctrine_Connection_Oracle extends Doctrine_Connection
|
||||
{
|
||||
/**
|
||||
* @var string $driverName the name of this connection driver
|
||||
*/
|
||||
protected $driverName = 'Oracle';
|
||||
|
||||
public function __construct(Doctrine_Manager $manager, $adapter) {
|
||||
public function __construct(Doctrine_Manager $manager, $adapter)
|
||||
{
|
||||
$this->supported = array(
|
||||
'sequences' => true,
|
||||
'indexes' => true,
|
||||
@ -76,7 +78,8 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
|
||||
* @param integer $offset start reading from given offset
|
||||
* @return string the modified query
|
||||
*/
|
||||
public function modifyLimitQuery($query, $limit, $offset) {
|
||||
public function modifyLimitQuery($query, $limit, $offset)
|
||||
{
|
||||
/**
|
||||
$e = explode("select ",strtolower($query));
|
||||
$e2 = explode(" from ",$e[1]);
|
||||
@ -107,7 +110,8 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
|
||||
* @throws PDOException if something went wrong at database level
|
||||
* @return integer
|
||||
*/
|
||||
public function nextId($sequence) {
|
||||
public function nextId($sequence)
|
||||
{
|
||||
$stmt = $this->query('SELECT ' . $sequence . '.nextval FROM dual');
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
@ -119,7 +123,8 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
|
||||
* @throws PDOException if something went wrong at database level
|
||||
* @return mixed id
|
||||
*/
|
||||
public function currId($sequence) {
|
||||
public function currId($sequence)
|
||||
{
|
||||
$sequence = $this->quoteIdentifier($this->getSequenceName($sequence), true);
|
||||
$stmt = $this->query('SELECT ' . $sequence . '.currval FROM dual');
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
|
||||
* @category Object Relational Mapping
|
||||
* @link www.phpdoctrine.com
|
||||
*/
|
||||
class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception {
|
||||
class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception
|
||||
{
|
||||
/**
|
||||
* @var array $errorCodeMap an array that is used for determining portable
|
||||
* error code from a native database error code
|
||||
@ -66,7 +67,8 @@ class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception
|
||||
* @return boolean whether or not the error info processing was successfull
|
||||
* (the process is successfull if portable error code was found)
|
||||
*/
|
||||
public function processErrorInfo(array $errorInfo) {
|
||||
public function processErrorInfo(array $errorInfo)
|
||||
{
|
||||
$code = $errorInfo[1];
|
||||
if (isset(self::$errorCodeMap[$code])) {
|
||||
$this->portableCode = self::$errorCodeMap[$code];
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload("Doctrine_Connection_Common");
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
|
||||
{
|
||||
/**
|
||||
* @var string $driverName the name of this connection driver
|
||||
*/
|
||||
@ -42,7 +43,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
* @param Doctrine_Manager $manager
|
||||
* @param PDO $pdo database handle
|
||||
*/
|
||||
public function __construct(Doctrine_Manager $manager, $adapter) {
|
||||
public function __construct(Doctrine_Manager $manager, $adapter)
|
||||
{
|
||||
// initialize all driver options
|
||||
$this->supported = array(
|
||||
'sequences' => true,
|
||||
@ -82,7 +84,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCharset($charset) {
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$query = 'SET NAMES '.$this->dbh->quote($charset);
|
||||
$this->dbh->query($query);
|
||||
}
|
||||
@ -91,7 +94,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
* @param string $sequence
|
||||
* @return integer
|
||||
*/
|
||||
public function nextId($sequence) {
|
||||
public function nextId($sequence)
|
||||
{
|
||||
$stmt = $this->dbh->query("SELECT NEXTVAL('$sequence')");
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
@ -102,7 +106,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
* @param string $seq_name name of the sequence
|
||||
* @return integer
|
||||
*/
|
||||
public function currId($sequence) {
|
||||
public function currId($sequence)
|
||||
{
|
||||
$stmt = $this->dbh->query('SELECT last_value FROM '.$sequence);
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
@ -116,7 +121,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
* @param boolean $isManip if the query is a DML query
|
||||
* @return string modified query
|
||||
*/
|
||||
public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) {
|
||||
public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false)
|
||||
{
|
||||
if ($limit > 0) {
|
||||
$query = rtrim($query);
|
||||
|
||||
@ -148,7 +154,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
* @param string $native determines if the raw version string should be returned
|
||||
* @return array|string an array or string with version information
|
||||
*/
|
||||
public function getServerVersion($native = false) {
|
||||
public function getServerVersion($native = false)
|
||||
{
|
||||
$query = 'SHOW SERVER_VERSION';
|
||||
|
||||
$serverInfo = $this->fetchOne($query);
|
||||
|
@ -32,7 +32,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception {
|
||||
class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception
|
||||
{
|
||||
/**
|
||||
* @var array $errorRegexps an array that is used for determining portable
|
||||
* error code from a native database error message
|
||||
@ -93,7 +94,8 @@ class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception
|
||||
* @return boolean whether or not the error info processing was successfull
|
||||
* (the process is successfull if portable error code was found)
|
||||
*/
|
||||
public function processErrorInfo(array $errorInfo) {
|
||||
public function processErrorInfo(array $errorInfo)
|
||||
{
|
||||
foreach (self::$errorRegexps as $regexp => $code) {
|
||||
if (preg_match($regexp, $errorInfo[2])) {
|
||||
$this->portableCode = $code;
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload("Doctrine_Connection_Common");
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
|
||||
class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
|
||||
{
|
||||
/**
|
||||
* @var string $driverName the name of this connection driver
|
||||
*/
|
||||
@ -42,7 +43,8 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
|
||||
* @param Doctrine_Manager $manager
|
||||
* @param PDO $pdo database handle
|
||||
*/
|
||||
public function __construct(Doctrine_Manager $manager, $adapter) {
|
||||
public function __construct(Doctrine_Manager $manager, $adapter)
|
||||
{
|
||||
|
||||
$this->supported = array(
|
||||
'sequences' => 'emulated',
|
||||
@ -76,7 +78,8 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
|
||||
/**
|
||||
* initializes database functions missing in sqlite
|
||||
*/
|
||||
public function initFunctions() {
|
||||
public function initFunctions()
|
||||
{
|
||||
$this->dbh->sqliteCreateFunction('md5', array('Doctrine_Expression_Sqlite', 'md5Impl'), 1);
|
||||
$this->dbh->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2);
|
||||
$this->dbh->sqliteCreateFunction('concat', array('Doctrine_Expression_Sqlite', 'concatImpl'));
|
||||
@ -88,7 +91,8 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
|
||||
* @param string $seq_name name of the sequence
|
||||
* @return integer the current id in the given sequence
|
||||
*/
|
||||
public function currId($sequence) {
|
||||
public function currId($sequence)
|
||||
{
|
||||
$sequence = $this->quoteIdentifier($sequence, true);
|
||||
$seqColumn = $this->quoteIdentifier($this->options['seqcol_name'], true);
|
||||
$stmt = $this->dbh->query('SELECT MAX(' . $seqColumn . ') FROM ' . $sequence);
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Exception');
|
||||
* @category Object Relational Mapping
|
||||
* @link www.phpdoctrine.com
|
||||
*/
|
||||
class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception {
|
||||
class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
|
||||
{
|
||||
/**
|
||||
* @var array $errorRegexps an array that is used for determining portable
|
||||
* error code from a native database error message
|
||||
@ -62,7 +63,8 @@ class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
|
||||
* @return boolean whether or not the error info processing was successfull
|
||||
* (the process is successfull if portable error code was found)
|
||||
*/
|
||||
public function processErrorInfo(array $errorInfo) {
|
||||
public function processErrorInfo(array $errorInfo)
|
||||
{
|
||||
foreach (self::$errorRegexps as $regexp => $code) {
|
||||
if (preg_match($regexp, $errorInfo[2])) {
|
||||
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Connection_Module');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implements IteratorAggregate, Countable {
|
||||
class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implements IteratorAggregate, Countable
|
||||
{
|
||||
/**
|
||||
* buildFlushTree
|
||||
* builds a flush tree that is used in transactions
|
||||
@ -42,7 +43,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
|
||||
* @param array $tables
|
||||
* @return array
|
||||
*/
|
||||
public function buildFlushTree(array $tables) {
|
||||
public function buildFlushTree(array $tables)
|
||||
{
|
||||
$tree = array();
|
||||
foreach ($tables as $k => $table) {
|
||||
$k = $k.$table;
|
||||
@ -135,7 +137,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
|
||||
* @throws PDOException if something went wrong at database level
|
||||
* @param Doctrine_Record $record
|
||||
*/
|
||||
public function saveRelated(Doctrine_Record $record) {
|
||||
public function saveRelated(Doctrine_Record $record)
|
||||
{
|
||||
$saveLater = array();
|
||||
foreach ($record->getReferences() as $k=>$v) {
|
||||
$fk = $record->getTable()->getRelation($k);
|
||||
@ -181,7 +184,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function saveAssociations(Doctrine_Record $record) {
|
||||
public function saveAssociations(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($record->getTable()->getRelations() as $rel) {
|
||||
$table = $rel->getTable();
|
||||
$alias = $rel->getAlias();
|
||||
@ -196,7 +200,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
|
||||
* @throws PDOException if something went wrong at database level
|
||||
* @return void
|
||||
*/
|
||||
public function deleteComposites(Doctrine_Record $record) {
|
||||
public function deleteComposites(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($record->getTable()->getRelations() as $fk) {
|
||||
switch ($fk->getType()) {
|
||||
case Doctrine_Relation::ONE_COMPOSITE:
|
||||
@ -214,7 +219,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
|
||||
* @throws PDOException if something went wrong at database level
|
||||
* @return void
|
||||
*/
|
||||
public function saveAll() {
|
||||
public function saveAll()
|
||||
{
|
||||
// get the flush tree
|
||||
$tree = $this->buildFlushTree($this->conn->getTables());
|
||||
|
||||
@ -242,7 +248,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
|
||||
* @param Doctrine_Record $record
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(Doctrine_Record $record) {
|
||||
public function update(Doctrine_Record $record)
|
||||
{
|
||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreUpdate($record);
|
||||
|
||||
$array = $record->getPrepared();
|
||||
@ -295,7 +302,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
|
||||
* @param Doctrine_Record $record record to be inserted
|
||||
* @return boolean
|
||||
*/
|
||||
public function insert(Doctrine_Record $record) {
|
||||
public function insert(Doctrine_Record $record)
|
||||
{
|
||||
// listen the onPreInsert event
|
||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreInsert($record);
|
||||
|
||||
@ -333,7 +341,9 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
|
||||
|
||||
return true;
|
||||
}
|
||||
public function getIterator() { }
|
||||
public function getIterator()
|
||||
{ }
|
||||
|
||||
public function count() { }
|
||||
public function count()
|
||||
{ }
|
||||
}
|
||||
|
@ -30,7 +30,8 @@
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
|
||||
*/
|
||||
class Doctrine_DataDict extends Doctrine_Connection_Module {
|
||||
class Doctrine_DataDict extends Doctrine_Connection_Module
|
||||
{
|
||||
/**
|
||||
* Obtain an array of changes that may need to applied
|
||||
*
|
||||
@ -38,7 +39,8 @@ class Doctrine_DataDict extends Doctrine_Connection_Module {
|
||||
* @param array $previous old definition
|
||||
* @return array containing all changes that will need to be applied
|
||||
*/
|
||||
public function compareDefinition($current, $previous) {
|
||||
public function compareDefinition($current, $previous)
|
||||
{
|
||||
$type = !empty($current['type']) ? $current['type'] : null;
|
||||
|
||||
if (!method_exists($this, "_compare{$type}Definition")) {
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_DataDict_Exception extends Doctrine_Exception { }
|
||||
class Doctrine_DataDict_Exception extends Doctrine_Exception
|
||||
{ }
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_DataDict');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
|
||||
class Doctrine_DataDict_Firebird extends Doctrine_DataDict
|
||||
{
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
@ -53,7 +54,8 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
*/
|
||||
public function getNativeDeclaration($field) {
|
||||
public function getNativeDeclaration($field)
|
||||
{
|
||||
switch ($field['type']) {
|
||||
case 'varchar':
|
||||
case 'string':
|
||||
@ -96,7 +98,8 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
|
||||
* @param array $field native field description
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
*/
|
||||
public function getPortableDeclaration($field) {
|
||||
public function getPortableDeclaration($field)
|
||||
{
|
||||
$length = $field['length'];
|
||||
|
||||
if ((int) $length <= 0)
|
||||
@ -181,7 +184,8 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration.
|
||||
*/
|
||||
public function getCharsetFieldDeclaration($charset) {
|
||||
public function getCharsetFieldDeclaration($charset)
|
||||
{
|
||||
return 'CHARACTER SET '.$charset;
|
||||
}
|
||||
/**
|
||||
@ -192,7 +196,8 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion needed to set the COLLATION
|
||||
* of a field declaration.
|
||||
*/
|
||||
public function getCollationFieldDeclaration($collation) {
|
||||
public function getCollationFieldDeclaration($collation)
|
||||
{
|
||||
return 'COLLATE '.$collation;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ Doctrine::autoload('Doctrine_DataDict');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_DataDict_Informix extends Doctrine_DataDict {
|
||||
class Doctrine_DataDict_Informix extends Doctrine_DataDict
|
||||
{
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
@ -53,7 +54,8 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
*/
|
||||
public function getNativeDeclaration($field) {
|
||||
public function getNativeDeclaration($field)
|
||||
{
|
||||
switch ($field['type']) {
|
||||
case 'char':
|
||||
case 'varchar':
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Informix_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_DataDict_Informix_Exception extends Doctrine_DataDict_Exception { }
|
||||
class Doctrine_DataDict_Informix_Exception extends Doctrine_DataDict_Exception
|
||||
{ }
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_DataDict');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_DataDict_Mssql extends Doctrine_DataDict {
|
||||
class Doctrine_DataDict_Mssql extends Doctrine_DataDict
|
||||
{
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
@ -55,7 +56,8 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
*/
|
||||
public function getNativeDeclaration($field) {
|
||||
public function getNativeDeclaration($field)
|
||||
{
|
||||
switch ($field['type']) {
|
||||
case 'array':
|
||||
case 'object':
|
||||
@ -111,7 +113,8 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict {
|
||||
* @param array $field native field description
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
*/
|
||||
public function getPortableDeclaration($field) {
|
||||
public function getPortableDeclaration($field)
|
||||
{
|
||||
$db_type = preg_replace('/\d/','', strtolower($field['type']) );
|
||||
$length = $field['length'];
|
||||
if ((int)$length <= 0) {
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_DataDict_Mssql_Exception extends Doctrine_DataDict_Exception { }
|
||||
class Doctrine_DataDict_Mssql_Exception extends Doctrine_DataDict_Exception
|
||||
{ }
|
||||
|
@ -29,7 +29,8 @@ Doctrine::autoload('Doctrine_DataDict');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
|
||||
class Doctrine_DataDict_Mysql extends Doctrine_DataDict
|
||||
{
|
||||
protected $keywords = array(
|
||||
'ADD', 'ALL', 'ALTER',
|
||||
'ANALYZE', 'AND', 'AS',
|
||||
@ -218,7 +219,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
|
||||
* @param array $field native field description
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
*/
|
||||
public function getPortableDeclaration(array $field) {
|
||||
public function getPortableDeclaration(array $field)
|
||||
{
|
||||
$dbType = strtolower($field['type']);
|
||||
$dbType = strtok($dbType, '(), ');
|
||||
if ($dbType == 'national') {
|
||||
@ -362,7 +364,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration.
|
||||
*/
|
||||
public function getCharsetFieldDeclaration($charset) {
|
||||
public function getCharsetFieldDeclaration($charset)
|
||||
{
|
||||
return 'CHARACTER SET '.$charset;
|
||||
}
|
||||
/**
|
||||
@ -373,7 +376,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion needed to set the COLLATION
|
||||
* of a field declaration.
|
||||
*/
|
||||
public function getCollationFieldDeclaration($collation) {
|
||||
public function getCollationFieldDeclaration($collation)
|
||||
{
|
||||
return 'COLLATE '.$collation;
|
||||
}
|
||||
/**
|
||||
@ -401,7 +405,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
*/
|
||||
public function getIntegerDeclaration($name, $field) {
|
||||
public function getIntegerDeclaration($name, $field)
|
||||
{
|
||||
$default = $autoinc = '';
|
||||
if (!empty($field['autoincrement'])) {
|
||||
$autoinc = ' AUTO_INCREMENT PRIMARY KEY';
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_DataDict_Mysql_Exception extends Doctrine_DataDict_Exception { }
|
||||
class Doctrine_DataDict_Mysql_Exception extends Doctrine_DataDict_Exception
|
||||
{ }
|
||||
|
@ -27,7 +27,8 @@
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_DataDict_Oracle extends Doctrine_DataDict {
|
||||
class Doctrine_DataDict_Oracle extends Doctrine_DataDict
|
||||
{
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
@ -50,7 +51,8 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
*/
|
||||
public function getNativeDeclaration(array $field) {
|
||||
public function getNativeDeclaration(array $field)
|
||||
{
|
||||
switch ($field['type']) {
|
||||
case 'string':
|
||||
case 'array':
|
||||
@ -93,7 +95,8 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict {
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
* @throws Doctrine_DataDict_Oracle_Exception
|
||||
*/
|
||||
public function getPortableDeclaration(array $field) {
|
||||
public function getPortableDeclaration(array $field)
|
||||
{
|
||||
$db_type = strtolower($field['type']);
|
||||
$type = array();
|
||||
$length = $unsigned = $fixed = null;
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_DataDict_Oracle_Exception extends Doctrine_DataDict_Exception { }
|
||||
class Doctrine_DataDict_Oracle_Exception extends Doctrine_DataDict_Exception
|
||||
{ }
|
||||
|
@ -29,7 +29,8 @@
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
|
||||
class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
|
||||
{
|
||||
/**
|
||||
* @param array $reservedKeyWords an array of reserved keywords by pgsql
|
||||
*/
|
||||
@ -355,7 +356,8 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
*/
|
||||
public function getNativeDeclaration(array $field) {
|
||||
public function getNativeDeclaration(array $field)
|
||||
{
|
||||
switch ($field['type']) {
|
||||
case 'char':
|
||||
case 'string':
|
||||
@ -420,7 +422,8 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
|
||||
*
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
*/
|
||||
public function getPortableDeclaration(array $field) {
|
||||
public function getPortableDeclaration(array $field)
|
||||
{
|
||||
|
||||
$length = $field['length'];
|
||||
if ($length == '-1' && isset($field['atttypmod'])) {
|
||||
@ -554,7 +557,8 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
*/
|
||||
public function getIntegerDeclaration($name, $field) {
|
||||
public function getIntegerDeclaration($name, $field)
|
||||
{
|
||||
/**
|
||||
if (!empty($field['unsigned'])) {
|
||||
$db->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer";
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
|
||||
* @version $Revision$
|
||||
* @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');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
|
||||
class Doctrine_DataDict_Sqlite extends Doctrine_DataDict
|
||||
{
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
@ -53,7 +54,8 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
*/
|
||||
public function getNativeDeclaration(array $field) {
|
||||
public function getNativeDeclaration(array $field)
|
||||
{
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'object':
|
||||
@ -118,7 +120,8 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
|
||||
* @param array $field native field description
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
*/
|
||||
public function getPortableDeclaration(array $field) {
|
||||
public function getPortableDeclaration(array $field)
|
||||
{
|
||||
$dbType = strtolower($field['type']);
|
||||
$length = ( ! empty($field['length'])) ? $field['length'] : null;
|
||||
$unsigned = ( ! empty($field['unsigned'])) ? $field['unsigned'] : null;
|
||||
@ -250,7 +253,8 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
|
||||
* declare the specified field.
|
||||
* @access protected
|
||||
*/
|
||||
public function getIntegerDeclaration($name, array $field) {
|
||||
public function getIntegerDeclaration($name, array $field)
|
||||
{
|
||||
$default = $autoinc = '';
|
||||
$type = $this->getNativeDeclaration($field);
|
||||
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
|
||||
* @version $Revision$
|
||||
* @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 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Interface {
|
||||
class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Interface
|
||||
{
|
||||
/**
|
||||
* @var array $instances all the instances of this class
|
||||
*/
|
||||
@ -91,7 +92,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
* @param string $user database username
|
||||
* @param string $pass database password
|
||||
*/
|
||||
public function __construct($dsn, $user, $pass) {
|
||||
public function __construct($dsn, $user, $pass)
|
||||
{
|
||||
if ( ! isset($user)) {
|
||||
$a = self::parseDSN($dsn);
|
||||
|
||||
@ -103,22 +105,26 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
$this->listener = new Doctrine_Db_EventListener();
|
||||
}
|
||||
|
||||
public function nextQuerySequence() {
|
||||
public function nextQuerySequence()
|
||||
{
|
||||
return ++$this->querySequence;
|
||||
}
|
||||
/**
|
||||
* getQuerySequence
|
||||
*/
|
||||
public function getQuerySequence() {
|
||||
public function getQuerySequence()
|
||||
{
|
||||
return $this->querySequence;
|
||||
}
|
||||
/**
|
||||
* getDBH
|
||||
*/
|
||||
public function getDBH() {
|
||||
public function getDBH()
|
||||
{
|
||||
return $this->dbh;
|
||||
}
|
||||
public function getOption($name) {
|
||||
public function getOption($name)
|
||||
{
|
||||
if ( ! array_key_exists($name, $this->options)) {
|
||||
throw new Doctrine_Db_Exception('Unknown option ' . $name);
|
||||
}
|
||||
@ -130,7 +136,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
* @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener
|
||||
* @return Doctrine_Db
|
||||
*/
|
||||
public function addListener($listener, $name = null) {
|
||||
public function addListener($listener, $name = null)
|
||||
{
|
||||
if ( ! ($this->listener instanceof Doctrine_Db_EventListener_Chain)) {
|
||||
$this->listener = new Doctrine_Db_EventListener_Chain();
|
||||
}
|
||||
@ -143,7 +150,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return Doctrine_Db_EventListener_Interface|Doctrine_Overloadable
|
||||
*/
|
||||
public function getListener() {
|
||||
public function getListener()
|
||||
{
|
||||
return $this->listener;
|
||||
}
|
||||
/**
|
||||
@ -152,7 +160,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
* @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener
|
||||
* @return Doctrine_Db
|
||||
*/
|
||||
public function setListener($listener) {
|
||||
public function setListener($listener)
|
||||
{
|
||||
if ( ! ($listener instanceof Doctrine_Db_EventListener_Interface)
|
||||
&& ! ($listener instanceof Doctrine_Overloadable)
|
||||
) {
|
||||
@ -169,7 +178,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function connect() {
|
||||
public function connect()
|
||||
{
|
||||
if ($this->isConnected)
|
||||
return false;
|
||||
|
||||
@ -188,7 +198,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static function getConnection($dsn = null, $username = null, $password = null) {
|
||||
public static function getConnection($dsn = null, $username = null, $password = null)
|
||||
{
|
||||
return new self($dsn, $username, $password);
|
||||
}
|
||||
/**
|
||||
@ -199,7 +210,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public static function driverName($name) {
|
||||
public static function driverName($name)
|
||||
{
|
||||
if (isset(self::$driverMap[$name])) {
|
||||
return self::$driverMap[$name];
|
||||
}
|
||||
@ -211,7 +223,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
* @param string $dsn
|
||||
* @return array Parsed contents of DSN
|
||||
*/
|
||||
function parseDSN($dsn) {
|
||||
function parseDSN($dsn)
|
||||
{
|
||||
// silence any warnings
|
||||
$parts = @parse_url($dsn);
|
||||
|
||||
@ -271,7 +284,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function clear() {
|
||||
public static function clear()
|
||||
{
|
||||
self::$instances = array();
|
||||
}
|
||||
|
||||
@ -281,7 +295,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function errorCode() {
|
||||
public function errorCode()
|
||||
{
|
||||
return $this->dbh->errorCode();
|
||||
}
|
||||
/**
|
||||
@ -290,7 +305,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function errorInfo() {
|
||||
public function errorInfo()
|
||||
{
|
||||
return $this->dbh->errorInfo();
|
||||
}
|
||||
/**
|
||||
@ -298,7 +314,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @param string $statement
|
||||
*/
|
||||
public function prepare($statement) {
|
||||
public function prepare($statement)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::PREPARE, $statement);
|
||||
@ -345,7 +362,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
public function quote($input) {
|
||||
public function quote($input)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
return $this->dbh->quote($input);
|
||||
@ -357,7 +375,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
* @param string $statement
|
||||
* @return integer
|
||||
*/
|
||||
public function exec($statement) {
|
||||
public function exec($statement)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
$args = func_get_args();
|
||||
@ -378,7 +397,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function lastInsertId() {
|
||||
public function lastInsertId()
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
return $this->dbh->lastInsertId();
|
||||
@ -388,7 +408,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function beginTransaction() {
|
||||
public function beginTransaction()
|
||||
{
|
||||
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::BEGIN);
|
||||
|
||||
$this->listener->onPreBeginTransaction($event);
|
||||
@ -404,7 +425,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function commit() {
|
||||
public function commit()
|
||||
{
|
||||
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::COMMIT);
|
||||
|
||||
$this->listener->onPreCommit($event);
|
||||
@ -420,7 +442,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function rollBack() {
|
||||
public function rollBack()
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::ROLLBACK);
|
||||
@ -438,7 +461,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
* @param integer $attribute
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttribute($attribute) {
|
||||
public function getAttribute($attribute)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
return $this->dbh->getAttribute($attribute);
|
||||
@ -446,7 +470,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
/**
|
||||
* returns an array of available PDO drivers
|
||||
*/
|
||||
public static function getAvailableDrivers() {
|
||||
public static function getAvailableDrivers()
|
||||
{
|
||||
return PDO::getAvailableDrivers();
|
||||
}
|
||||
/**
|
||||
@ -457,7 +482,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
* @param mixed $value
|
||||
* @return boolean
|
||||
*/
|
||||
public function setAttribute($attribute, $value) {
|
||||
public function setAttribute($attribute, $value)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
$this->dbh->setAttribute($attribute, $value);
|
||||
@ -467,7 +493,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator()
|
||||
{
|
||||
if ($this->listener instanceof Doctrine_Db_Profiler)
|
||||
return $this->listener;
|
||||
}
|
||||
@ -477,7 +504,8 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function count() {
|
||||
public function count()
|
||||
{
|
||||
return $this->querySequence;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,8 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Db_Event {
|
||||
class Doctrine_Db_Event
|
||||
{
|
||||
const QUERY = 1;
|
||||
const EXEC = 2;
|
||||
const EXECUTE = 3;
|
||||
@ -47,28 +48,35 @@ class Doctrine_Db_Event {
|
||||
|
||||
protected $endedMicrotime;
|
||||
|
||||
public function __construct($invoker, $type, $query = null) {
|
||||
public function __construct($invoker, $type, $query = null)
|
||||
{
|
||||
$this->invoker = $invoker;
|
||||
$this->type = $type;
|
||||
$this->query = $query;
|
||||
}
|
||||
public function getQuery() {
|
||||
public function getQuery()
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
public function getType() {
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function start() {
|
||||
public function start()
|
||||
{
|
||||
$this->startedMicrotime = microtime(true);
|
||||
}
|
||||
public function hasEnded() {
|
||||
public function hasEnded()
|
||||
{
|
||||
return ($this->endedMicrotime != null);
|
||||
}
|
||||
public function end() {
|
||||
public function end()
|
||||
{
|
||||
$this->endedMicrotime = microtime(true);
|
||||
}
|
||||
public function getInvoker() {
|
||||
public function getInvoker()
|
||||
{
|
||||
return $this->invoker;
|
||||
}
|
||||
/**
|
||||
@ -77,7 +85,8 @@ class Doctrine_Db_Event {
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getElapsedSecs() {
|
||||
public function getElapsedSecs()
|
||||
{
|
||||
if (is_null($this->endedMicrotime)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -29,25 +29,40 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Db_EventListener implements Doctrine_Db_EventListener_Interface {
|
||||
public function onPreQuery(Doctrine_Db_Event $event) { }
|
||||
public function onQuery(Doctrine_Db_Event $event) { }
|
||||
class Doctrine_Db_EventListener implements Doctrine_Db_EventListener_Interface
|
||||
{
|
||||
public function onPreQuery(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
public function onQuery(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
|
||||
public function onPrePrepare(Doctrine_Db_Event $event) { }
|
||||
public function onPrepare(Doctrine_Db_Event $event) { }
|
||||
public function onPrePrepare(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
public function onPrepare(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
|
||||
public function onPreCommit(Doctrine_Db_Event $event) { }
|
||||
public function onCommit(Doctrine_Db_Event $event) { }
|
||||
public function onPreCommit(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
public function onCommit(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
|
||||
public function onPreExec(Doctrine_Db_Event $event) { }
|
||||
public function onExec(Doctrine_Db_Event $event) { }
|
||||
public function onPreExec(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
public function onExec(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
|
||||
public function onPreRollBack(Doctrine_Db_Event $event) { }
|
||||
public function onRollBack(Doctrine_Db_Event $event) { }
|
||||
public function onPreRollBack(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
public function onRollBack(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
|
||||
public function onPreBeginTransaction(Doctrine_Db_Event $event) { }
|
||||
public function onBeginTransaction(Doctrine_Db_Event $event) { }
|
||||
public function onPreBeginTransaction(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
public function onBeginTransaction(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
|
||||
public function onPreExecute(Doctrine_Db_Event $event) { }
|
||||
public function onExecute(Doctrine_Db_Event $event) { }
|
||||
public function onPreExecute(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
public function onExecute(Doctrine_Db_Event $event)
|
||||
{ }
|
||||
}
|
||||
|
@ -31,10 +31,12 @@ Doctrine::autoload('Doctrine_Access');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrine_Db_EventListener_Interface {
|
||||
class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrine_Db_EventListener_Interface
|
||||
{
|
||||
private $listeners = array();
|
||||
|
||||
public function add($listener, $name = null) {
|
||||
public function add($listener, $name = null)
|
||||
{
|
||||
if ( ! ($listener instanceof Doctrine_Db_EventListener_Interface)
|
||||
&& ! ($listener instanceof Doctrine_Overloadable)
|
||||
) {
|
||||
@ -47,14 +49,16 @@ class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrin
|
||||
}
|
||||
}
|
||||
|
||||
public function get($name) {
|
||||
public function get($name)
|
||||
{
|
||||
if ( ! isset($this->listeners[$name])) {
|
||||
throw new Doctrine_Db_Exception("Unknown listener $name");
|
||||
}
|
||||
return $this->listeners[$name];
|
||||
}
|
||||
|
||||
public function set($name, $listener) {
|
||||
public function set($name, $listener)
|
||||
{
|
||||
if ( ! ($listener instanceof Doctrine_Db_EventListener_Interface)
|
||||
&& ! ($listener instanceof Doctrine_Overloadable)
|
||||
) {
|
||||
@ -63,78 +67,92 @@ class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrin
|
||||
$this->listeners[$name] = $listener;
|
||||
}
|
||||
|
||||
public function onQuery(Doctrine_Db_Event $event) {
|
||||
public function onQuery(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onQuery($event);
|
||||
}
|
||||
}
|
||||
public function onPreQuery(Doctrine_Db_Event $event) {
|
||||
public function onPreQuery(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreQuery($event);
|
||||
}
|
||||
}
|
||||
|
||||
public function onPreExec(Doctrine_Db_Event $event) {
|
||||
public function onPreExec(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreExec($event);
|
||||
}
|
||||
}
|
||||
public function onExec(Doctrine_Db_Event $event) {
|
||||
public function onExec(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onExec($event);
|
||||
}
|
||||
}
|
||||
|
||||
public function onPrePrepare(Doctrine_Db_Event $event) {
|
||||
public function onPrePrepare(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPrePrepare($event);
|
||||
}
|
||||
}
|
||||
public function onPrepare(Doctrine_Db_Event $event) {
|
||||
public function onPrepare(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPrepare($event);
|
||||
}
|
||||
}
|
||||
|
||||
public function onPreCommit(Doctrine_Db_Event $event) {
|
||||
public function onPreCommit(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreCommit($event);
|
||||
}
|
||||
}
|
||||
public function onCommit(Doctrine_Db_Event $event) {
|
||||
public function onCommit(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onCommit($event);
|
||||
}
|
||||
}
|
||||
|
||||
public function onPreRollBack(Doctrine_Db_Event $event) {
|
||||
public function onPreRollBack(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreRollBack($event);
|
||||
}
|
||||
}
|
||||
public function onRollBack(Doctrine_Db_Event $event) {
|
||||
public function onRollBack(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onRollBack($event);
|
||||
}
|
||||
}
|
||||
|
||||
public function onPreBeginTransaction(Doctrine_Db_Event $event) {
|
||||
public function onPreBeginTransaction(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreBeginTransaction($event);
|
||||
}
|
||||
}
|
||||
public function onBeginTransaction(Doctrine_Db_Event $event) {
|
||||
public function onBeginTransaction(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onBeginTransaction($event);
|
||||
}
|
||||
}
|
||||
|
||||
public function onPreExecute(Doctrine_Db_Event $event) {
|
||||
public function onPreExecute(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreExecute($event);
|
||||
}
|
||||
}
|
||||
public function onExecute(Doctrine_Db_Event $event) {
|
||||
public function onExecute(Doctrine_Db_Event $event)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onExecute($event);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Db_Exception extends Doctrine_Exception {
|
||||
class Doctrine_Db_Exception extends Doctrine_Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ Doctrine::autoload('Doctrine_Db');
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Db_Mock extends Doctrine_Db {
|
||||
class Doctrine_Db_Mock extends Doctrine_Db
|
||||
{
|
||||
protected static $errorCodeMap = array(
|
||||
1004 => Doctrine::ERR_CANNOT_CREATE,
|
||||
1005 => Doctrine::ERR_CANNOT_CREATE,
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Overloadable');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Db_Profiler implements Doctrine_Overloadable {
|
||||
class Doctrine_Db_Profiler implements Doctrine_Overloadable
|
||||
{
|
||||
/**
|
||||
* @param array $listeners an array containing all availible listeners
|
||||
*/
|
||||
@ -56,7 +57,8 @@ class Doctrine_Db_Profiler implements Doctrine_Overloadable {
|
||||
* @see Doctrine_Db_EventListener
|
||||
* @return void
|
||||
*/
|
||||
public function __call($m, $a) {
|
||||
public function __call($m, $a)
|
||||
{
|
||||
// first argument should be an instance of Doctrine_Db_Event
|
||||
if ( ! ($a[0] instanceof Doctrine_Db_Event)) {
|
||||
throw new Doctrine_Db_Profiler_Exception("Couldn't listen event. Event should be an instance of Doctrine_Db_Event.");
|
||||
@ -83,7 +85,8 @@ class Doctrine_Db_Profiler implements Doctrine_Overloadable {
|
||||
*
|
||||
* @return Doctrine_Db_Event
|
||||
*/
|
||||
public function lastEvent() {
|
||||
public function lastEvent()
|
||||
{
|
||||
if (empty($this->events)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Db_Exception');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Db_Profiler_Exception extends Doctrine_Db_Exception { }
|
||||
class Doctrine_Db_Profiler_Exception extends Doctrine_Db_Exception
|
||||
{ }
|
||||
|
@ -29,7 +29,8 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Db_Profiler_Query {
|
||||
class Doctrine_Db_Profiler_Query
|
||||
{
|
||||
/**
|
||||
* @var string SQL query string or user comment, set by $query argument in constructor.
|
||||
*/
|
||||
@ -60,7 +61,8 @@ class Doctrine_Db_Profiler_Query {
|
||||
* @param string $query
|
||||
* @param int $queryType
|
||||
*/
|
||||
public function __construct($query, $prepareTime = null) {
|
||||
public function __construct($query, $prepareTime = null)
|
||||
{
|
||||
$this->query = $query;
|
||||
if ($prepareTime !== null) {
|
||||
$this->prepareTime = $prepareTime;
|
||||
@ -68,7 +70,8 @@ class Doctrine_Db_Profiler_Query {
|
||||
$this->startedMicrotime = microtime(true);
|
||||
}
|
||||
}
|
||||
public function start() {
|
||||
public function start()
|
||||
{
|
||||
$this->startedMicrotime = microtime(true);
|
||||
}
|
||||
/**
|
||||
@ -76,12 +79,14 @@ class Doctrine_Db_Profiler_Query {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function end() {
|
||||
public function end()
|
||||
{
|
||||
$this->endedMicrotime = microtime(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getPrepareTime() {
|
||||
public function getPrepareTime()
|
||||
{
|
||||
return $this->prepareTime;
|
||||
}
|
||||
|
||||
@ -90,7 +95,8 @@ class Doctrine_Db_Profiler_Query {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEnded() {
|
||||
public function hasEnded()
|
||||
{
|
||||
return ($this->endedMicrotime != null);
|
||||
}
|
||||
|
||||
@ -99,7 +105,8 @@ class Doctrine_Db_Profiler_Query {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQuery() {
|
||||
public function getQuery()
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
@ -108,7 +115,8 @@ class Doctrine_Db_Profiler_Query {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getQueryType() {
|
||||
public function getQueryType()
|
||||
{
|
||||
return $this->queryType;
|
||||
}
|
||||
/**
|
||||
@ -117,7 +125,8 @@ class Doctrine_Db_Profiler_Query {
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getElapsedSecs() {
|
||||
public function getElapsedSecs()
|
||||
{
|
||||
if (is_null($this->endedMicrotime) && ! $this->prepareTime) {
|
||||
return false;
|
||||
}
|
||||
|
@ -29,7 +29,8 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Db_Statement extends PDOStatement {
|
||||
class Doctrine_Db_Statement extends PDOStatement
|
||||
{
|
||||
protected $dbh;
|
||||
|
||||
protected $querySequence;
|
||||
@ -38,28 +39,34 @@ class Doctrine_Db_Statement extends PDOStatement {
|
||||
|
||||
protected $executed = false;
|
||||
|
||||
protected function __construct($dbh) {
|
||||
protected function __construct($dbh)
|
||||
{
|
||||
$this->dbh = $dbh;
|
||||
$this->baseSequence = $this->querySequence = $this->dbh->getQuerySequence();
|
||||
}
|
||||
|
||||
public function getQuerySequence() {
|
||||
public function getQuerySequence()
|
||||
{
|
||||
return $this->querySequence;
|
||||
}
|
||||
public function getBaseSequence() {
|
||||
public function getBaseSequence()
|
||||
{
|
||||
return $this->baseSequence;
|
||||
}
|
||||
public function getQuery() {
|
||||
public function getQuery()
|
||||
{
|
||||
return $this->queryString;
|
||||
}
|
||||
public function isExecuted($executed = null) {
|
||||
public function isExecuted($executed = null)
|
||||
{
|
||||
if ($executed === null)
|
||||
return $this->executed;
|
||||
|
||||
$this->executed = (bool) $executed;
|
||||
}
|
||||
|
||||
public function execute(array $params = null) {
|
||||
public function execute(array $params = null)
|
||||
{
|
||||
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::EXECUTE, $this->queryString);
|
||||
|
||||
$this->dbh->getListener()->onPreExecute($event);
|
||||
|
@ -32,54 +32,84 @@ Doctrine::autoload('Doctrine_EventListener_Interface');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_EventListener implements Doctrine_EventListener_Interface {
|
||||
class Doctrine_EventListener implements Doctrine_EventListener_Interface
|
||||
{
|
||||
|
||||
public function onLoad(Doctrine_Record $record) { }
|
||||
public function onPreLoad(Doctrine_Record $record) { }
|
||||
public function onLoad(Doctrine_Record $record)
|
||||
{ }
|
||||
public function onPreLoad(Doctrine_Record $record)
|
||||
{ }
|
||||
|
||||
public function onSleep(Doctrine_Record $record) { }
|
||||
public function onSleep(Doctrine_Record $record)
|
||||
{ }
|
||||
|
||||
public function onWakeUp(Doctrine_Record $record) { }
|
||||
public function onWakeUp(Doctrine_Record $record)
|
||||
{ }
|
||||
|
||||
public function onUpdate(Doctrine_Record $record) { }
|
||||
public function onPreUpdate(Doctrine_Record $record) { }
|
||||
public function onUpdate(Doctrine_Record $record)
|
||||
{ }
|
||||
public function onPreUpdate(Doctrine_Record $record)
|
||||
{ }
|
||||
|
||||
public function onCreate(Doctrine_Record $record) { }
|
||||
public function onPreCreate(Doctrine_Record $record) { }
|
||||
public function onCreate(Doctrine_Record $record)
|
||||
{ }
|
||||
public function onPreCreate(Doctrine_Record $record)
|
||||
{ }
|
||||
|
||||
public function onSave(Doctrine_Record $record) { }
|
||||
public function onPreSave(Doctrine_Record $record) { }
|
||||
public function onSave(Doctrine_Record $record)
|
||||
{ }
|
||||
public function onPreSave(Doctrine_Record $record)
|
||||
{ }
|
||||
|
||||
public function onGetProperty(Doctrine_Record $record, $property, $value) {
|
||||
public function onGetProperty(Doctrine_Record $record, $property, $value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
public function onSetProperty(Doctrine_Record $record, $property, $value) {
|
||||
public function onSetProperty(Doctrine_Record $record, $property, $value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function onInsert(Doctrine_Record $record) { }
|
||||
public function onPreInsert(Doctrine_Record $record) { }
|
||||
public function onInsert(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 onPreDelete(Doctrine_Record $record)
|
||||
{ }
|
||||
|
||||
public function onEvict(Doctrine_Record $record) { }
|
||||
public function onPreEvict(Doctrine_Record $record) { }
|
||||
public function onEvict(Doctrine_Record $record)
|
||||
{ }
|
||||
public function onPreEvict(Doctrine_Record $record)
|
||||
{ }
|
||||
|
||||
public function onClose(Doctrine_Connection $connection) { }
|
||||
public function onPreClose(Doctrine_Connection $connection) { }
|
||||
public function onClose(Doctrine_Connection $connection)
|
||||
{ }
|
||||
public function onPreClose(Doctrine_Connection $connection)
|
||||
{ }
|
||||
|
||||
public function onOpen(Doctrine_Connection $connection) { }
|
||||
public function onOpen(Doctrine_Connection $connection)
|
||||
{ }
|
||||
|
||||
public function onTransactionCommit(Doctrine_Connection $connection) { }
|
||||
public function onPreTransactionCommit(Doctrine_Connection $connection) { }
|
||||
public function onTransactionCommit(Doctrine_Connection $connection)
|
||||
{ }
|
||||
public function onPreTransactionCommit(Doctrine_Connection $connection)
|
||||
{ }
|
||||
|
||||
public function onTransactionRollback(Doctrine_Connection $connection) { }
|
||||
public function onPreTransactionRollback(Doctrine_Connection $connection) { }
|
||||
public function onTransactionRollback(Doctrine_Connection $connection)
|
||||
{ }
|
||||
public function onPreTransactionRollback(Doctrine_Connection $connection)
|
||||
{ }
|
||||
|
||||
public function onTransactionBegin(Doctrine_Connection $connection) { }
|
||||
public function onPreTransactionBegin(Doctrine_Connection $connection) { }
|
||||
public function onTransactionBegin(Doctrine_Connection $connection)
|
||||
{ }
|
||||
public function onPreTransactionBegin(Doctrine_Connection $connection)
|
||||
{ }
|
||||
|
||||
public function onCollectionDelete(Doctrine_Collection $collection) { }
|
||||
public function onPreCollectionDelete(Doctrine_Collection $collection) { }
|
||||
public function onCollectionDelete(Doctrine_Collection $collection)
|
||||
{ }
|
||||
public function onPreCollectionDelete(Doctrine_Collection $collection)
|
||||
{ }
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_EventListener');
|
||||
* @since 1.0
|
||||
* @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
|
||||
*/
|
||||
@ -47,7 +48,8 @@ class Doctrine_EventListener_AccessorInvoker extends Doctrine_EventListener {
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function onGetProperty(Doctrine_Record $record, $property, $value) {
|
||||
public function onGetProperty(Doctrine_Record $record, $property, $value)
|
||||
{
|
||||
$method = 'get' . ucwords($property);
|
||||
|
||||
if (method_exists($record, $method) && ! $this->lockGetCall) {
|
||||
@ -67,7 +69,8 @@ class Doctrine_EventListener_AccessorInvoker extends Doctrine_EventListener {
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function onSetProperty(Doctrine_Record $record, $property, $value) {
|
||||
public function onSetProperty(Doctrine_Record $record, $property, $value)
|
||||
{
|
||||
$method = 'set' . ucwords($property);
|
||||
|
||||
if (method_exists($record, $method) && ! $this->lockSetCall) {
|
||||
|
@ -33,7 +33,8 @@ Doctrine::autoload('Doctrine_Access');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_EventListener_Interface {
|
||||
class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_EventListener_Interface
|
||||
{
|
||||
/**
|
||||
* @var array $listeners an array containing all listeners
|
||||
*/
|
||||
@ -44,7 +45,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_EventListener $listener
|
||||
* @return void
|
||||
*/
|
||||
public function add(Doctrine_EventListener $listener) {
|
||||
public function add(Doctrine_EventListener $listener)
|
||||
{
|
||||
$this->listeners[] = $listener;
|
||||
}
|
||||
/**
|
||||
@ -54,7 +56,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param mixed $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key) {
|
||||
public function get($key)
|
||||
{
|
||||
if ( ! isset($this->listeners[$key])) {
|
||||
return null;
|
||||
}
|
||||
@ -67,7 +70,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_EventListener $listener
|
||||
* @return void
|
||||
*/
|
||||
public function set($key, Doctrine_EventListener $listener) {
|
||||
public function set($key, Doctrine_EventListener $listener)
|
||||
{
|
||||
$this->listeners[$key] = $listener;
|
||||
}
|
||||
/**
|
||||
@ -77,7 +81,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onLoad(Doctrine_Record $record) {
|
||||
public function onLoad(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onLoad($record);
|
||||
}
|
||||
@ -90,7 +95,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onPreLoad(Doctrine_Record $record) {
|
||||
public function onPreLoad(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreLoad($record);
|
||||
}
|
||||
@ -102,7 +108,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onSleep(Doctrine_Record $record) {
|
||||
public function onSleep(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onSleep($record);
|
||||
}
|
||||
@ -114,7 +121,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onWakeUp(Doctrine_Record $record) {
|
||||
public function onWakeUp(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onWakeUp($record);
|
||||
}
|
||||
@ -126,7 +134,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onUpdate(Doctrine_Record $record) {
|
||||
public function onUpdate(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onUpdate($record);
|
||||
}
|
||||
@ -138,7 +147,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onPreUpdate(Doctrine_Record $record) {
|
||||
public function onPreUpdate(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreUpdate($record);
|
||||
}
|
||||
@ -150,7 +160,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onCreate(Doctrine_Record $record) {
|
||||
public function onCreate(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onCreate($record);
|
||||
}
|
||||
@ -163,7 +174,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onPreCreate(Doctrine_Record $record) {
|
||||
public function onPreCreate(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreCreate($record);
|
||||
}
|
||||
@ -175,7 +187,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onSave(Doctrine_Record $record) {
|
||||
public function onSave(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onSave($record);
|
||||
}
|
||||
@ -187,7 +200,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onPreSave(Doctrine_Record $record) {
|
||||
public function onPreSave(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreSave($record);
|
||||
}
|
||||
@ -201,7 +215,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function onGetProperty(Doctrine_Record $record, $property, $value) {
|
||||
public function onGetProperty(Doctrine_Record $record, $property, $value)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$value = $listener->onGetProperty($record, $property, $value);
|
||||
}
|
||||
@ -216,7 +231,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function onSetProperty(Doctrine_Record $record, $property, $value) {
|
||||
public function onSetProperty(Doctrine_Record $record, $property, $value)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$value = $listener->onSetProperty($record, $property, $value);
|
||||
}
|
||||
@ -229,7 +245,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onInsert(Doctrine_Record $record) {
|
||||
public function onInsert(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onInsert($record);
|
||||
}
|
||||
@ -241,7 +258,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onPreInsert(Doctrine_Record $record) {
|
||||
public function onPreInsert(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreInsert($record);
|
||||
}
|
||||
@ -253,7 +271,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onDelete(Doctrine_Record $record) {
|
||||
public function onDelete(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onDelete($record);
|
||||
}
|
||||
@ -265,7 +284,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onPreDelete(Doctrine_Record $record) {
|
||||
public function onPreDelete(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreDelete($record);
|
||||
}
|
||||
@ -277,7 +297,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onEvict(Doctrine_Record $record) {
|
||||
public function onEvict(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onEvict($record);
|
||||
}
|
||||
@ -289,7 +310,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Record $record
|
||||
* @return void
|
||||
*/
|
||||
public function onPreEvict(Doctrine_Record $record) {
|
||||
public function onPreEvict(Doctrine_Record $record)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreEvict($record);
|
||||
}
|
||||
@ -301,7 +323,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Connection $connection
|
||||
* @return void
|
||||
*/
|
||||
public function onClose(Doctrine_Connection $connection) {
|
||||
public function onClose(Doctrine_Connection $connection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onClose($connection);
|
||||
}
|
||||
@ -313,7 +336,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Connection $connection
|
||||
* @return void
|
||||
*/
|
||||
public function onPreClose(Doctrine_Connection $connection) {
|
||||
public function onPreClose(Doctrine_Connection $connection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreClose($connection);
|
||||
}
|
||||
@ -325,7 +349,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Connection $connection
|
||||
* @return void
|
||||
*/
|
||||
public function onOpen(Doctrine_Connection $connection) {
|
||||
public function onOpen(Doctrine_Connection $connection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onOpen($connection);
|
||||
}
|
||||
@ -337,7 +362,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Connection $connection
|
||||
* @return void
|
||||
*/
|
||||
public function onTransactionCommit(Doctrine_Connection $connection) {
|
||||
public function onTransactionCommit(Doctrine_Connection $connection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onTransactionCommit($connection);
|
||||
}
|
||||
@ -349,7 +375,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Connection $connection
|
||||
* @return void
|
||||
*/
|
||||
public function onPreTransactionCommit(Doctrine_Connection $connection) {
|
||||
public function onPreTransactionCommit(Doctrine_Connection $connection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreTransactionCommit($connection);
|
||||
}
|
||||
@ -361,7 +388,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Connection $connection
|
||||
* @return void
|
||||
*/
|
||||
public function onTransactionRollback(Doctrine_Connection $connection) {
|
||||
public function onTransactionRollback(Doctrine_Connection $connection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onTransactionRollback($connection);
|
||||
}
|
||||
@ -373,7 +401,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Connection $connection
|
||||
* @return void
|
||||
*/
|
||||
public function onPreTransactionRollback(Doctrine_Connection $connection) {
|
||||
public function onPreTransactionRollback(Doctrine_Connection $connection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreTransactionRollback($connection);
|
||||
}
|
||||
@ -385,7 +414,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Connection $connection
|
||||
* @return void
|
||||
*/
|
||||
public function onTransactionBegin(Doctrine_Connection $connection) {
|
||||
public function onTransactionBegin(Doctrine_Connection $connection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onTransactionBegin($connection);
|
||||
}
|
||||
@ -397,7 +427,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Connection $connection
|
||||
* @return void
|
||||
*/
|
||||
public function onPreTransactionBegin(Doctrine_Connection $connection) {
|
||||
public function onPreTransactionBegin(Doctrine_Connection $connection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreTransactionBegin($connection);
|
||||
}
|
||||
@ -409,7 +440,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Collection $collection
|
||||
* @return void
|
||||
*/
|
||||
public function onCollectionDelete(Doctrine_Collection $collection) {
|
||||
public function onCollectionDelete(Doctrine_Collection $collection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onCollectionDelete($record);
|
||||
}
|
||||
@ -421,7 +453,8 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
* @param Doctrine_Collection $collection
|
||||
* @return void
|
||||
*/
|
||||
public function onPreCollectionDelete(Doctrine_Collection $collection) {
|
||||
public function onPreCollectionDelete(Doctrine_Collection $collection)
|
||||
{
|
||||
foreach ($this->listeners as $listener) {
|
||||
$listener->onPreCollectionDelete($collection);
|
||||
}
|
||||
|
@ -1,21 +1,26 @@
|
||||
<?php
|
||||
Doctrine::autoload("EventListener");
|
||||
|
||||
class Doctrine_DebugMessage {
|
||||
class Doctrine_DebugMessage
|
||||
{
|
||||
private $code;
|
||||
private $object;
|
||||
public function __construct($object, $code) {
|
||||
public function __construct($object, $code)
|
||||
{
|
||||
$this->object = $object;
|
||||
$this->code = $code;
|
||||
}
|
||||
final public function getCode() {
|
||||
final public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
final public function getObject() {
|
||||
final public function getObject()
|
||||
{
|
||||
return $this->object;
|
||||
}
|
||||
}
|
||||
class Doctrine_EventListener_Debugger extends Doctrine_EventListener {
|
||||
class Doctrine_EventListener_Debugger extends Doctrine_EventListener
|
||||
{
|
||||
|
||||
const EVENT_LOAD = 1;
|
||||
const EVENT_PRELOAD = 2;
|
||||
@ -48,103 +53,131 @@ class Doctrine_EventListener_Debugger extends Doctrine_EventListener {
|
||||
const EVENT_PRECOLLDELETE = 27;
|
||||
private $debug;
|
||||
|
||||
public function getMessages() {
|
||||
public function getMessages()
|
||||
{
|
||||
return $this->debug;
|
||||
}
|
||||
|
||||
public function onLoad(Doctrine_Record $record) {
|
||||
public function onLoad(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_LOAD);
|
||||
}
|
||||
public function onPreLoad(Doctrine_Record $record) {
|
||||
public function onPreLoad(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PRELOAD);
|
||||
}
|
||||
|
||||
public function onSleep(Doctrine_Record $record) {
|
||||
public function onSleep(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_SLEEP);
|
||||
}
|
||||
|
||||
public function onWakeUp(Doctrine_Record $record) {
|
||||
public function onWakeUp(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_WAKEUP);
|
||||
}
|
||||
|
||||
public function onUpdate(Doctrine_Record $record) {
|
||||
public function onUpdate(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_UPDATE);
|
||||
}
|
||||
public function onPreUpdate(Doctrine_Record $record) {
|
||||
public function onPreUpdate(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREUPDATE);
|
||||
}
|
||||
|
||||
public function onCreate(Doctrine_Record $record) {
|
||||
public function onCreate(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_CREATE);
|
||||
}
|
||||
public function onPreCreate(Doctrine_Record $record) {
|
||||
public function onPreCreate(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PRECREATE);
|
||||
}
|
||||
|
||||
public function onSave(Doctrine_Record $record) {
|
||||
public function onSave(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_SAVE);
|
||||
}
|
||||
public function onPreSave(Doctrine_Record $record) {
|
||||
public function onPreSave(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PRESAVE);
|
||||
}
|
||||
|
||||
public function onInsert(Doctrine_Record $record) {
|
||||
public function onInsert(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_INSERT);
|
||||
}
|
||||
public function onPreInsert(Doctrine_Record $record) {
|
||||
public function onPreInsert(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREINSERT);
|
||||
}
|
||||
|
||||
public function onDelete(Doctrine_Record $record) {
|
||||
public function onDelete(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_DELETE);
|
||||
}
|
||||
public function onPreDelete(Doctrine_Record $record) {
|
||||
public function onPreDelete(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREDELETE);
|
||||
}
|
||||
|
||||
public function onEvict(Doctrine_Record $record) {
|
||||
public function onEvict(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_EVICT);
|
||||
}
|
||||
public function onPreEvict(Doctrine_Record $record) {
|
||||
public function onPreEvict(Doctrine_Record $record)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREEVICT);
|
||||
}
|
||||
|
||||
public function onClose(Doctrine_Connection $connection) {
|
||||
public function onClose(Doctrine_Connection $connection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_CLOSE);
|
||||
}
|
||||
public function onPreClose(Doctrine_Connection $connection) {
|
||||
public function onPreClose(Doctrine_Connection $connection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_PRECLOSE);
|
||||
}
|
||||
|
||||
public function onOpen(Doctrine_Connection $connection) {
|
||||
public function onOpen(Doctrine_Connection $connection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_OPEN);
|
||||
}
|
||||
|
||||
public function onTransactionCommit(Doctrine_Connection $connection) {
|
||||
public function onTransactionCommit(Doctrine_Connection $connection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_COMMIT);
|
||||
}
|
||||
public function onPreTransactionCommit(Doctrine_Connection $connection) {
|
||||
public function onPreTransactionCommit(Doctrine_Connection $connection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_PRECOMMIT);
|
||||
}
|
||||
|
||||
public function onTransactionRollback(Doctrine_Connection $connection) {
|
||||
public function onTransactionRollback(Doctrine_Connection $connection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_ROLLBACK);
|
||||
}
|
||||
public function onPreTransactionRollback(Doctrine_Connection $connection) {
|
||||
public function onPreTransactionRollback(Doctrine_Connection $connection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_PREROLLBACK);
|
||||
}
|
||||
|
||||
public function onTransactionBegin(Doctrine_Connection $connection) {
|
||||
public function onTransactionBegin(Doctrine_Connection $connection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_BEGIN);
|
||||
}
|
||||
public function onPreTransactionBegin(Doctrine_Connection $connection) {
|
||||
public function onPreTransactionBegin(Doctrine_Connection $connection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($connection,self::EVENT_PREBEGIN);
|
||||
}
|
||||
|
||||
public function onCollectionDelete(Doctrine_Collection $collection) {
|
||||
public function onCollectionDelete(Doctrine_Collection $collection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($collection,self::EVENT_COLLDELETE);
|
||||
}
|
||||
public function onPreCollectionDelete(Doctrine_Collection $collection) {
|
||||
public function onPreCollectionDelete(Doctrine_Collection $collection)
|
||||
{
|
||||
$this->debug[] = new Doctrine_DebugMessage($collection,self::EVENT_PRECOLLDELETE);
|
||||
}
|
||||
}
|
||||
|
@ -9,4 +9,5 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_EventListener_Empty extends Doctrine_EventListener { }
|
||||
class Doctrine_EventListener_Empty extends Doctrine_EventListener
|
||||
{ }
|
||||
|
@ -29,4 +29,5 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Exception extends Exception { }
|
||||
class Doctrine_Exception extends Exception
|
||||
{ }
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Connection_Module');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
class Doctrine_Export extends Doctrine_Connection_Module
|
||||
{
|
||||
/**
|
||||
* drop an existing database
|
||||
* (this method is implemented by the drivers)
|
||||
@ -39,7 +40,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @param string $name name of the database that should be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function dropDatabase($database) {
|
||||
public function dropDatabase($database)
|
||||
{
|
||||
throw new Doctrine_Export_Exception('Drop database not supported by this driver.');
|
||||
}
|
||||
/**
|
||||
@ -50,7 +52,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @throws PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function dropTable($table) {
|
||||
public function dropTable($table)
|
||||
{
|
||||
$this->conn->execute('DROP TABLE ' . $table);
|
||||
}
|
||||
|
||||
@ -61,7 +64,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @param string $name name of the index to be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function dropIndex($table, $name) {
|
||||
public function dropIndex($table, $name)
|
||||
{
|
||||
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
|
||||
return $this->conn->exec('DROP INDEX ' . $name);
|
||||
}
|
||||
@ -73,7 +77,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @param string $primary hint if the constraint is primary
|
||||
* @return void
|
||||
*/
|
||||
public function dropConstraint($table, $name, $primary = false) {
|
||||
public function dropConstraint($table, $name, $primary = false)
|
||||
{
|
||||
$table = $this->conn->quoteIdentifier($table, true);
|
||||
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
|
||||
return $this->conn->exec('ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $name);
|
||||
@ -85,7 +90,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @param string $seq_name name of the sequence to be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function dropSequence($name) {
|
||||
public function dropSequence($name)
|
||||
{
|
||||
throw new Doctrine_Export_Exception('Drop sequence not supported by this driver.');
|
||||
}
|
||||
/**
|
||||
@ -95,7 +101,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @param string $name name of the database that should be created
|
||||
* @return void
|
||||
*/
|
||||
public function createDatabase($database) {
|
||||
public function createDatabase($database)
|
||||
{
|
||||
throw new Doctrine_Export_Exception('Create database not supported by this driver.');
|
||||
}
|
||||
/**
|
||||
@ -152,7 +159,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @param string $start start value of the sequence; default is 1
|
||||
* @return void
|
||||
*/
|
||||
public function createSequence($seqName, $seqcolName, $start = 1) {
|
||||
public function createSequence($seqName, $seqcolName, $start = 1)
|
||||
{
|
||||
throw new Doctrine_Export_Exception('Create sequence not supported by this driver.');
|
||||
}
|
||||
|
||||
@ -177,7 +185,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* )
|
||||
* @return void
|
||||
*/
|
||||
public function createConstraint($table, $name, $definition) {
|
||||
public function createConstraint($table, $name, $definition)
|
||||
{
|
||||
$table = $this->conn->quoteIdentifier($table, true);
|
||||
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
|
||||
$query = "ALTER TABLE $table ADD CONSTRAINT $name";
|
||||
@ -225,7 +234,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* )
|
||||
* @return void
|
||||
*/
|
||||
public function createIndex($table, $name, array $definition) {
|
||||
public function createIndex($table, $name, array $definition)
|
||||
{
|
||||
return $this->conn->execute($this->createIndexSql($table, $name, $definition));
|
||||
}
|
||||
/**
|
||||
@ -260,7 +270,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* )
|
||||
* @return string
|
||||
*/
|
||||
public function createIndexSql($table, $name, array $definition) {
|
||||
public function createIndexSql($table, $name, array $definition)
|
||||
{
|
||||
$table = $this->conn->quoteIdentifier($table);
|
||||
$name = $this->conn->quoteIdentifier($name);
|
||||
|
||||
@ -362,7 +373,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* actually perform them otherwise.
|
||||
* @return void
|
||||
*/
|
||||
public function alterTable($name, array $changes, $check) {
|
||||
public function alterTable($name, array $changes, $check)
|
||||
{
|
||||
$this->conn->execute($this->alterTableSql($name, $changes, $check));
|
||||
}
|
||||
/**
|
||||
@ -454,7 +466,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* actually perform them otherwise.
|
||||
* @return string
|
||||
*/
|
||||
public function alterTableSql($name, array $changes, $check) {
|
||||
public function alterTableSql($name, array $changes, $check)
|
||||
{
|
||||
throw new Doctrine_Export_Exception('Alter table not supported by this driver.');
|
||||
}
|
||||
/**
|
||||
@ -484,7 +497,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldDeclarationList(array $fields) {
|
||||
public function getFieldDeclarationList(array $fields)
|
||||
{
|
||||
foreach ($fields as $fieldName => $field) {
|
||||
$query = $this->getDeclaration($fieldName, $field);
|
||||
|
||||
@ -519,7 +533,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
*/
|
||||
public function getDeclaration($name, array $field) {
|
||||
public function getDeclaration($name, array $field)
|
||||
{
|
||||
|
||||
$default = '';
|
||||
if (isset($field['default'])) {
|
||||
@ -567,7 +582,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration.
|
||||
*/
|
||||
public function getCharsetFieldDeclaration($charset) {
|
||||
public function getCharsetFieldDeclaration($charset)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
@ -578,7 +594,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
* @return string DBMS specific SQL code portion needed to set the COLLATION
|
||||
* of a field declaration.
|
||||
*/
|
||||
public function getCollationFieldDeclaration($collation) {
|
||||
public function getCollationFieldDeclaration($collation)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
@ -587,7 +604,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function exportAll() {
|
||||
public static function exportAll()
|
||||
{
|
||||
$parent = new ReflectionClass('Doctrine_Record');
|
||||
$conn = Doctrine_Manager::getInstance()->getCurrentConnection();
|
||||
$old = $conn->getAttribute(Doctrine::ATTR_CREATE_TABLES);
|
||||
@ -603,7 +621,8 @@ class Doctrine_Export extends Doctrine_Connection_Module {
|
||||
}
|
||||
$conn->setAttribute(Doctrine::ATTR_CREATE_TABLES, $old);
|
||||
}
|
||||
public function export($record) {
|
||||
public function export($record)
|
||||
{
|
||||
if ( ! $record instanceof Doctrine_Record)
|
||||
$record = new $record();
|
||||
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Export_Exception extends Doctrine_Exception { }
|
||||
class Doctrine_Export_Exception extends Doctrine_Exception
|
||||
{ }
|
||||
|
@ -32,14 +32,16 @@ Doctrine::autoload('Doctrine_Export');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
class Doctrine_Export_Firebird extends Doctrine_Export
|
||||
{
|
||||
/**
|
||||
* create a new database
|
||||
*
|
||||
* @param string $name name of the database that should be created
|
||||
* @return void
|
||||
*/
|
||||
public function createDatabase($name) {
|
||||
public function createDatabase($name)
|
||||
{
|
||||
throw new Doctrine_Export_Firebird_Exception(
|
||||
'PHP Interbase API does not support direct queries. You have to ' .
|
||||
'create the db manually by using isql command or a similar program');
|
||||
@ -50,7 +52,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* @param string $name name of the database that should be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function dropDatabase($name) {
|
||||
public function dropDatabase($name)
|
||||
{
|
||||
throw new Doctrine_Export_Firebird_Exception(
|
||||
'PHP Interbase API does not support direct queries. You have ' .
|
||||
'to drop the db manually by using isql command or a similar program');
|
||||
@ -63,7 +66,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* @param string $start start value for the sequence
|
||||
* @return void
|
||||
*/
|
||||
public function _makeAutoincrement($name, $table, $start = null) {
|
||||
public function _makeAutoincrement($name, $table, $start = null)
|
||||
{
|
||||
if (is_null($start)) {
|
||||
$this->conn->beginTransaction();
|
||||
$query = 'SELECT MAX(' . $this->conn->quoteIdentifier($name, true) . ') FROM ' . $this->conn->quoteIdentifier($table, true);
|
||||
@ -101,7 +105,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* @param string $table name of the table
|
||||
* @return void
|
||||
*/
|
||||
public function _dropAutoincrement($table) {
|
||||
public function _dropAutoincrement($table)
|
||||
{
|
||||
|
||||
$result = $this->dropSequence($table);
|
||||
|
||||
@ -180,7 +185,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* @param string $name name of the database that should be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function checkSupportedChanges(&$changes) {
|
||||
public function checkSupportedChanges(&$changes)
|
||||
{
|
||||
foreach ($changes as $change_name => $change) {
|
||||
switch ($change_name) {
|
||||
case 'notnull':
|
||||
@ -213,7 +219,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* @return mixed MDB2_OK on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
public function dropTable($name) {
|
||||
public function dropTable($name)
|
||||
{
|
||||
$result = $this->_dropAutoincrement($name);
|
||||
$result = parent::dropTable($name);
|
||||
|
||||
@ -309,7 +316,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* actually perform them otherwise.
|
||||
* @return void
|
||||
*/
|
||||
public function alterTable($name, $changes, $check) {
|
||||
public function alterTable($name, $changes, $check)
|
||||
{
|
||||
foreach ($changes as $change_name => $change) {
|
||||
switch ($change_name) {
|
||||
case 'add':
|
||||
@ -416,7 +424,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* )
|
||||
* @return void
|
||||
*/
|
||||
public function createIndex($table, $name, array $definition) {
|
||||
public function createIndex($table, $name, array $definition)
|
||||
{
|
||||
$query = 'CREATE';
|
||||
|
||||
$query_sort = '';
|
||||
@ -466,7 +475,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* )
|
||||
* @return void
|
||||
*/
|
||||
public function createConstraint($table, $name, $definition) {
|
||||
public function createConstraint($table, $name, $definition)
|
||||
{
|
||||
$table = $this->conn->quoteIdentifier($table, true);
|
||||
|
||||
if (!empty($name)) {
|
||||
@ -500,7 +510,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* @param string $start start value of the sequence; default is 1
|
||||
* @return void
|
||||
*/
|
||||
public function createSequence($seqName, $start = 1) {
|
||||
public function createSequence($seqName, $start = 1)
|
||||
{
|
||||
$sequenceName = $this->conn->getSequenceName($seqName);
|
||||
|
||||
$this->conn->exec('CREATE GENERATOR ' . $sequenceName);
|
||||
@ -515,7 +526,8 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
|
||||
* @param string $seq_name name of the sequence to be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function dropSequence($seq_name) {
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
$sequence_name = $this->conn->getSequenceName($seq_name);
|
||||
$sequence_name = $this->conn->getDbh()->quote($sequence_name);
|
||||
$query = "DELETE FROM RDB\$GENERATORS WHERE UPPER(RDB\$GENERATOR_NAME)=$sequence_name";
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Export_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Export_Firebird_Exception extends Doctrine_Export_Exception { }
|
||||
class Doctrine_Export_Firebird_Exception extends Doctrine_Export_Exception
|
||||
{ }
|
||||
|
@ -32,14 +32,16 @@ Doctrine::autoload('Doctrine_Export');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Mssql extends Doctrine_Export {
|
||||
class Doctrine_Export_Mssql extends Doctrine_Export
|
||||
{
|
||||
/**
|
||||
* create a new database
|
||||
*
|
||||
* @param string $name name of the database that should be created
|
||||
* @return void
|
||||
*/
|
||||
public function createDatabase($name) {
|
||||
public function createDatabase($name)
|
||||
{
|
||||
$name = $db->quoteIdentifier($name, true);
|
||||
$query = "CREATE DATABASE $name";
|
||||
if ($db->options['database_device']) {
|
||||
@ -55,7 +57,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
|
||||
* @param string $name name of the database that should be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function dropDatabase($name) {
|
||||
public function dropDatabase($name)
|
||||
{
|
||||
$name = $db->quoteIdentifier($name, true);
|
||||
return $db->standaloneQuery("DROP DATABASE $name", null, true);
|
||||
}
|
||||
@ -147,7 +150,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
|
||||
* actually perform them otherwise.
|
||||
* @return void
|
||||
*/
|
||||
public function alterTable($name, $changes, $check) {
|
||||
public function alterTable($name, $changes, $check)
|
||||
{
|
||||
foreach ($changes as $change_name => $change) {
|
||||
switch ($change_name) {
|
||||
case 'add':
|
||||
@ -197,7 +201,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
|
||||
* @param string $start start value of the sequence; default is 1
|
||||
* @return void
|
||||
*/
|
||||
public function createSequence($seq_name, $start = 1) {
|
||||
public function createSequence($seq_name, $start = 1)
|
||||
{
|
||||
$sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
|
||||
$seqcol_name = $db->quoteIdentifier($db->options['seqcol_name'], true);
|
||||
$query = "CREATE TABLE $sequence_name ($seqcol_name " .
|
||||
@ -228,7 +233,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
|
||||
* @param string $seqName name of the sequence to be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function dropSequence($seqName) {
|
||||
public function dropSequence($seqName)
|
||||
{
|
||||
$sequenceName = $db->quoteIdentifier($db->getSequenceName($seqName), true);
|
||||
return $this->conn->exec('DROP TABLE ' . $sequenceName);
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Export');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Mysql extends Doctrine_Export {
|
||||
class Doctrine_Export_Mysql extends Doctrine_Export
|
||||
{
|
||||
/**
|
||||
* create a new database
|
||||
*
|
||||
@ -39,7 +40,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
|
||||
* @throws PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function createDatabase($name) {
|
||||
public function createDatabase($name)
|
||||
{
|
||||
$query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true);
|
||||
$result = $this->conn->exec($query);
|
||||
}
|
||||
@ -50,7 +52,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
|
||||
* @throws PDOException
|
||||
* @access public
|
||||
*/
|
||||
public function dropDatabase($name) {
|
||||
public function dropDatabase($name)
|
||||
{
|
||||
$query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
|
||||
$this->conn->exec($query);
|
||||
}
|
||||
@ -221,7 +224,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
|
||||
* actually perform them otherwise.
|
||||
* @return boolean
|
||||
*/
|
||||
public function alterTable($name, array $changes, $check) {
|
||||
public function alterTable($name, array $changes, $check)
|
||||
{
|
||||
if ( ! $name)
|
||||
throw new Doctrine_Export_Mysql_Exception('no valid table name specified');
|
||||
|
||||
@ -316,7 +320,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
|
||||
* @param string $start start value of the sequence; default is 1
|
||||
* @return boolean
|
||||
*/
|
||||
public function createSequence($sequenceName, $seqcol_name, $start = 1) {
|
||||
public function createSequence($sequenceName, $seqcol_name, $start = 1)
|
||||
{
|
||||
$query = 'CREATE TABLE ' . $sequenceName
|
||||
. ' (' . $seqcol_name . ' INT NOT NULL AUTO_INCREMENT, PRIMARY KEY ('
|
||||
. $seqcol_name . '))'
|
||||
@ -376,7 +381,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
|
||||
* @throws PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function createIndex($table, $name, array $definition) {
|
||||
public function createIndex($table, $name, array $definition)
|
||||
{
|
||||
$table = $table;
|
||||
$name = $this->conn->getIndexName($name);
|
||||
$query = 'CREATE INDEX ' . $name . ' ON ' . $table;
|
||||
@ -399,7 +405,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
|
||||
* @param string $name name of the index to be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function dropIndex($table, $name) {
|
||||
public function dropIndex($table, $name)
|
||||
{
|
||||
$table = $this->conn->quoteIdentifier($table, true);
|
||||
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
|
||||
return $this->conn->exec('DROP INDEX ' . $name . ' ON ' . $table);
|
||||
@ -411,7 +418,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
|
||||
* @throws PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function dropTable($table) {
|
||||
public function dropTable($table)
|
||||
{
|
||||
$table = $this->conn->quoteIdentifier($table, true);
|
||||
$this->conn->exec('DROP TABLE ' . $table);
|
||||
}
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Export_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Export_Mysql_Exception extends Doctrine_Export_Exception { }
|
||||
class Doctrine_Export_Mysql_Exception extends Doctrine_Export_Exception
|
||||
{ }
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Export');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Oracle extends Doctrine_Export {
|
||||
class Doctrine_Export_Oracle extends Doctrine_Export
|
||||
{
|
||||
/**
|
||||
* create a new database
|
||||
*
|
||||
@ -420,7 +421,8 @@ END;
|
||||
* @param string $start start value of the sequence; default is 1
|
||||
* @return void
|
||||
*/
|
||||
public function createSequence($seqName, $start = 1) {
|
||||
public function createSequence($seqName, $start = 1)
|
||||
{
|
||||
$sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true);
|
||||
$query = 'CREATE SEQUENCE ' . $sequenceName . ' START WITH ' . $start . ' INCREMENT BY 1 NOCACHE';
|
||||
$query.= ($start < 1 ? ' MINVALUE ' . $start : '');
|
||||
@ -433,7 +435,8 @@ END;
|
||||
* @param string $seqName name of the sequence to be dropped
|
||||
* @return void
|
||||
*/
|
||||
public function dropSequence($seqName) {
|
||||
public function dropSequence($seqName)
|
||||
{
|
||||
$sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true);
|
||||
return $this->conn->exec('DROP SEQUENCE ' . $sequenceName);
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Export');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Pgsql extends Doctrine_Export {
|
||||
class Doctrine_Export_Pgsql extends Doctrine_Export
|
||||
{
|
||||
/**
|
||||
* create a new database
|
||||
*
|
||||
@ -39,7 +40,8 @@ class Doctrine_Export_Pgsql extends Doctrine_Export {
|
||||
* @throws PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function createDatabase($name) {
|
||||
public function createDatabase($name)
|
||||
{
|
||||
$query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name);
|
||||
$this->conn->exec($query);
|
||||
}
|
||||
@ -50,7 +52,8 @@ class Doctrine_Export_Pgsql extends Doctrine_Export {
|
||||
* @throws PDOException
|
||||
* @access public
|
||||
*/
|
||||
public function dropDatabase($name) {
|
||||
public function dropDatabase($name)
|
||||
{
|
||||
$query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
|
||||
$this->conn->exec($query);
|
||||
}
|
||||
@ -143,7 +146,8 @@ class Doctrine_Export_Pgsql extends Doctrine_Export {
|
||||
* @throws PDOException
|
||||
* @return boolean
|
||||
*/
|
||||
public function alterTable($name, $changes, $check) {
|
||||
public function alterTable($name, $changes, $check)
|
||||
{
|
||||
foreach ($changes as $change_name => $change) {
|
||||
switch ($change_name) {
|
||||
case 'add':
|
||||
|
@ -31,7 +31,8 @@ Doctrine::autoload('Doctrine_Export');
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Sqlite extends Doctrine_Export {
|
||||
class Doctrine_Export_Sqlite extends Doctrine_Export
|
||||
{
|
||||
/**
|
||||
* Get the stucture of a field into an array
|
||||
*
|
||||
@ -64,7 +65,8 @@ class Doctrine_Export_Sqlite extends Doctrine_Export {
|
||||
* @throws PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function createIndex($table, $name, array $definition) {
|
||||
public function createIndex($table, $name, array $definition)
|
||||
{
|
||||
$table = $this->conn->quoteIdentifier($table, true);
|
||||
$name = $this->conn->getIndexName($name);
|
||||
$query = 'CREATE INDEX ' . $name . ' ON ' . $table;
|
||||
|
@ -30,11 +30,14 @@ Doctrine::autoload('Doctrine_Connection_Module');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
public function getIdentifier($column) {
|
||||
class Doctrine_Expression extends Doctrine_Connection_Module
|
||||
{
|
||||
public function getIdentifier($column)
|
||||
{
|
||||
return $column;
|
||||
}
|
||||
public function getIdentifiers($columns) {
|
||||
public function getIdentifiers($columns)
|
||||
{
|
||||
return $columns;
|
||||
}
|
||||
/**
|
||||
@ -43,7 +46,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function regexp() {
|
||||
public function regexp()
|
||||
{
|
||||
throw new Doctrine_Expression_Exception('Regular expression operator is not supported by this database driver.');
|
||||
}
|
||||
/**
|
||||
@ -52,7 +56,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $column the column to use
|
||||
* @return string generated sql including an AVG aggregate function
|
||||
*/
|
||||
public function avg($column) {
|
||||
public function avg($column)
|
||||
{
|
||||
$column = $this->getIdentifier($column);
|
||||
return 'AVG(' . $column . ')';
|
||||
}
|
||||
@ -66,7 +71,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string|integer $column the column to use
|
||||
* @return string generated sql including a COUNT aggregate function
|
||||
*/
|
||||
public function count($column) {
|
||||
public function count($column)
|
||||
{
|
||||
$column = $this->getIdentifier($column);
|
||||
return 'COUNT(' . $column . ')';
|
||||
}
|
||||
@ -77,7 +83,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $column the column to use
|
||||
* @return string generated sql including a MAX aggregate function
|
||||
*/
|
||||
public function max($column) {
|
||||
public function max($column)
|
||||
{
|
||||
$column = $this->getIdentifier($column);
|
||||
return 'MAX(' . $column . ')';
|
||||
}
|
||||
@ -88,7 +95,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $column the column to use
|
||||
* @return string
|
||||
*/
|
||||
public function min($column) {
|
||||
public function min($column)
|
||||
{
|
||||
$column = $this->getIdentifier($column);
|
||||
return 'MIN(' . $column . ')';
|
||||
}
|
||||
@ -99,7 +107,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $column the column to use
|
||||
* @return string
|
||||
*/
|
||||
public function sum($column) {
|
||||
public function sum($column)
|
||||
{
|
||||
$column = $this->getIdentifier($column);
|
||||
return 'SUM(' . $column . ')';
|
||||
}
|
||||
@ -113,7 +122,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function md5($column) {
|
||||
public function md5($column)
|
||||
{
|
||||
$column = $this->getIdentifier($column);
|
||||
return 'MD5(' . $column . ')';
|
||||
}
|
||||
@ -125,7 +135,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $expression2
|
||||
* @return string
|
||||
*/
|
||||
public function length($column) {
|
||||
public function length($column)
|
||||
{
|
||||
$column = $this->getIdentifier($column);
|
||||
return 'LENGTH(' . $column . ')';
|
||||
}
|
||||
@ -137,7 +148,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $expression2
|
||||
* @return string
|
||||
*/
|
||||
public function round($column, $decimals = 0) {
|
||||
public function round($column, $decimals = 0)
|
||||
{
|
||||
$column = $this->getIdentifier($column);
|
||||
|
||||
return 'ROUND(' . $column . ', ' . $decimals . ')';
|
||||
@ -151,7 +163,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $expression2
|
||||
* @return string
|
||||
*/
|
||||
public function mod($expression1, $expression2) {
|
||||
public function mod($expression1, $expression2)
|
||||
{
|
||||
$expression1 = $this->getIdentifier($expression1);
|
||||
$expression2 = $this->getIdentifier($expression2);
|
||||
return 'MOD(' . $expression1 . ', ' . $expression2 . ')';
|
||||
@ -163,7 +176,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $str literal string or column name
|
||||
* @return string
|
||||
*/
|
||||
public function ltrim($str) {
|
||||
public function ltrim($str)
|
||||
{
|
||||
return 'LTRIM(' . $str . ')';
|
||||
}
|
||||
/**
|
||||
@ -174,7 +188,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $str literal string or column name
|
||||
* @return string
|
||||
*/
|
||||
public function upper($str) {
|
||||
public function upper($str)
|
||||
{
|
||||
return 'UPPER(' . $str . ')';
|
||||
}
|
||||
/**
|
||||
@ -185,7 +200,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $str literal string or column name
|
||||
* @return string
|
||||
*/
|
||||
public function lower($str) {
|
||||
public function lower($str)
|
||||
{
|
||||
return 'LOWER(' . $str . ')';
|
||||
}
|
||||
/**
|
||||
@ -196,7 +212,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $str literal string
|
||||
* @return integer
|
||||
*/
|
||||
public function locate($str, $substr) {
|
||||
public function locate($str, $substr)
|
||||
{
|
||||
return 'LOCATE(' . $str . ', ' . $substr . ')';
|
||||
}
|
||||
/**
|
||||
@ -204,7 +221,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function now() {
|
||||
public function now()
|
||||
{
|
||||
return 'NOW()';
|
||||
}
|
||||
/**
|
||||
@ -217,7 +235,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $value
|
||||
* @return string SQL soundex function with given parameter
|
||||
*/
|
||||
public function soundex($value) {
|
||||
public function soundex($value)
|
||||
{
|
||||
throw new Doctrine_Expression_Exception('SQL soundex function not supported by this driver.');
|
||||
}
|
||||
/**
|
||||
@ -232,7 +251,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param integer $length the substring portion length
|
||||
* @return string SQL substring function with given parameters
|
||||
*/
|
||||
public function substring($value, $from, $len = null) {
|
||||
public function substring($value, $from, $len = null)
|
||||
{
|
||||
$value = $this->getIdentifier($value);
|
||||
if ($len === null)
|
||||
return 'SUBSTRING(' . $value . ' FROM ' . $from . ')';
|
||||
@ -249,7 +269,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
*
|
||||
* @param string|array(string) strings that will be concatinated.
|
||||
*/
|
||||
public function concat(array $args) {
|
||||
public function concat(array $args)
|
||||
{
|
||||
$cols = $this->getIdentifiers($args);
|
||||
return 'CONCAT(' . join(', ', $cols) . ')';
|
||||
}
|
||||
@ -266,7 +287,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
*
|
||||
* @return string a logical expression
|
||||
*/
|
||||
public function not($expression) {
|
||||
public function not($expression)
|
||||
{
|
||||
$expression = $this->getIdentifier($expression);
|
||||
return 'NOT(' . $expression . ')';
|
||||
}
|
||||
@ -282,7 +304,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string|array(string)
|
||||
* @return string an expression
|
||||
*/
|
||||
private function basicMath($type, array $args) {
|
||||
private function basicMath($type, array $args)
|
||||
{
|
||||
$elements = $this->getIdentifiers($args);
|
||||
if (count($elements) < 1) {
|
||||
return '';
|
||||
@ -313,7 +336,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string|array(string)
|
||||
* @return string an expression
|
||||
*/
|
||||
public function add(array $args) {
|
||||
public function add(array $args)
|
||||
{
|
||||
return $this->basicMath('+', $args);
|
||||
}
|
||||
|
||||
@ -337,7 +361,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string|array(string)
|
||||
* @return string an expression
|
||||
*/
|
||||
public function sub(array $args) {
|
||||
public function sub(array $args)
|
||||
{
|
||||
return $this->basicMath('-', $args );
|
||||
}
|
||||
|
||||
@ -361,7 +386,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string|array(string)
|
||||
* @return string an expression
|
||||
*/
|
||||
public function mul(array $args) {
|
||||
public function mul(array $args)
|
||||
{
|
||||
return $this->basicMath('*', $args);
|
||||
}
|
||||
|
||||
@ -385,7 +411,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string|array(string)
|
||||
* @return string an expression
|
||||
*/
|
||||
public function div(array $args) {
|
||||
public function div(array $args)
|
||||
{
|
||||
return $this->basicMath('/', $args);
|
||||
}
|
||||
|
||||
@ -404,7 +431,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $value2 logical expression to compare with
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function eq($value1, $value2) {
|
||||
public function eq($value1, $value2)
|
||||
{
|
||||
$value1 = $this->getIdentifier($value1);
|
||||
$value2 = $this->getIdentifier($value2);
|
||||
return $value1 . ' = ' . $value2;
|
||||
@ -425,7 +453,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $value2 logical expression to compare with
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function neq($value1, $value2) {
|
||||
public function neq($value1, $value2)
|
||||
{
|
||||
$value1 = $this->getIdentifier($value1);
|
||||
$value2 = $this->getIdentifier($value2);
|
||||
return $value1 . ' <> ' . $value2;
|
||||
@ -446,7 +475,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $value2 logical expression to compare with
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function gt($value1, $value2) {
|
||||
public function gt($value1, $value2)
|
||||
{
|
||||
$value1 = $this->getIdentifier($value1);
|
||||
$value2 = $this->getIdentifier($value2);
|
||||
return $value1 . ' > ' . $value2;
|
||||
@ -468,7 +498,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $value2 logical expression to compare with
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function gte($value1, $value2) {
|
||||
public function gte($value1, $value2)
|
||||
{
|
||||
$value1 = $this->getIdentifier($value1);
|
||||
$value2 = $this->getIdentifier($value2);
|
||||
return $value1 . ' >= ' . $value2;
|
||||
@ -489,7 +520,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $value2 logical expression to compare with
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function lt($value1, $value2) {
|
||||
public function lt($value1, $value2)
|
||||
{
|
||||
$value1 = $this->getIdentifier($value1);
|
||||
$value2 = $this->getIdentifier($value2);
|
||||
return $value1 . ' < ' . $value2;
|
||||
@ -511,7 +543,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $value2 logical expression to compare with
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function lte($value1, $value2) {
|
||||
public function lte($value1, $value2)
|
||||
{
|
||||
$value1 = $this->getIdentifier($value1);
|
||||
$value2 = $this->getIdentifier($value2);
|
||||
return $value1 . ' <= ' . $value2;
|
||||
@ -538,7 +571,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string|array(string) values that will be matched against $column
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function in($column, $values) {
|
||||
public function in($column, $values)
|
||||
{
|
||||
if ( ! is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
@ -564,7 +598,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $expression the expression that should be compared to null
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function isNull($expression) {
|
||||
public function isNull($expression)
|
||||
{
|
||||
$expression = $this->getIdentifier($expression);
|
||||
return $expression . ' IS NULL';
|
||||
}
|
||||
@ -582,7 +617,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $expression the expression that should be compared to null
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function isNotNull($expression) {
|
||||
public function isNotNull($expression)
|
||||
{
|
||||
$expression = $this->getIdentifier($expression);
|
||||
return $expression . ' IS NOT NULL';
|
||||
}
|
||||
@ -609,7 +645,8 @@ class Doctrine_Expression extends Doctrine_Connection_Module {
|
||||
* @param string $value2 the higher value to compare with
|
||||
* @return string logical expression
|
||||
*/
|
||||
public function between($expression, $value1, $value2) {
|
||||
public function between($expression, $value1, $value2)
|
||||
{
|
||||
$expression = $this->getIdentifier($expression);
|
||||
$value1 = $this->getIdentifier($value1);
|
||||
$value2 = $this->getIdentifier($value2);
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Exception');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Expression_Exception extends Doctrine_Exception { }
|
||||
class Doctrine_Expression_Exception extends Doctrine_Exception
|
||||
{ }
|
||||
|
@ -32,14 +32,16 @@ Doctrine::autoload('Doctrine_Expression');
|
||||
* @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver)
|
||||
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
|
||||
*/
|
||||
class Doctrine_Expression_Firebird extends Doctrine_Expression {
|
||||
class Doctrine_Expression_Firebird extends Doctrine_Expression
|
||||
{
|
||||
/**
|
||||
* return string for internal table used when calling only a function
|
||||
*
|
||||
* @return string for internal table used when calling only a function
|
||||
* @access public
|
||||
*/
|
||||
public function functionTable() {
|
||||
public function functionTable()
|
||||
{
|
||||
return ' FROM RDB$DATABASE';
|
||||
}
|
||||
/**
|
||||
@ -47,7 +49,8 @@ class Doctrine_Expression_Firebird extends Doctrine_Expression {
|
||||
*
|
||||
* @return string define escape pattern
|
||||
*/
|
||||
function patternEscapeString() {
|
||||
function patternEscapeString()
|
||||
{
|
||||
return " ESCAPE '". $this->conn->string_quoting['escape_pattern'] ."'";
|
||||
}
|
||||
}
|
||||
|
@ -30,4 +30,5 @@ Doctrine::autoload('Doctrine_Expression');
|
||||
* @version $Revision$
|
||||
* @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');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Expression_Mssql extends Doctrine_Expression {
|
||||
class Doctrine_Expression_Mssql extends Doctrine_Expression
|
||||
{
|
||||
/**
|
||||
* Return string to call a variable with the current timestamp inside an SQL statement
|
||||
* There are three special variables for current date and time:
|
||||
@ -41,7 +42,8 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression {
|
||||
* @return string to call a variable with the current timestamp
|
||||
* @access public
|
||||
*/
|
||||
public function now($type = 'timestamp') {
|
||||
public function now($type = 'timestamp')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'time':
|
||||
case 'date':
|
||||
@ -55,7 +57,8 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression {
|
||||
*
|
||||
* @return string to call a function to get a substring
|
||||
*/
|
||||
public function substring($value, $position, $length = null) {
|
||||
public function substring($value, $position, $length = null)
|
||||
{
|
||||
if (!is_null($length)) {
|
||||
return "SUBSTRING($value, $position, $length)";
|
||||
}
|
||||
@ -70,7 +73,8 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression {
|
||||
* @return string to concatenate two strings
|
||||
* @access public
|
||||
**/
|
||||
function concat($arg1, $arg2) {
|
||||
function concat($arg1, $arg2)
|
||||
{
|
||||
$args = func_get_args();
|
||||
return '(' . implode(' + ', $args) . ')';
|
||||
}
|
||||
|
@ -30,13 +30,15 @@ Doctrine::autoload('Doctrine_Expression');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Expression_Mysql extends Doctrine_Expression {
|
||||
class Doctrine_Expression_Mysql extends Doctrine_Expression
|
||||
{
|
||||
/**
|
||||
* returns the regular expression operator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function regexp() {
|
||||
public function regexp()
|
||||
{
|
||||
return 'RLIKE';
|
||||
}
|
||||
/**
|
||||
@ -56,7 +58,8 @@ class Doctrine_Expression_Mysql extends Doctrine_Expression {
|
||||
*
|
||||
* @return string SQL pattern
|
||||
*/
|
||||
public function matchPattern($pattern, $operator = null, $field = null) {
|
||||
public function matchPattern($pattern, $operator = null, $field = null)
|
||||
{
|
||||
$match = '';
|
||||
if (!is_null($operator)) {
|
||||
$field = is_null($field) ? '' : $field.' ';
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Expression');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Expression_Oracle extends Doctrine_Expression {
|
||||
class Doctrine_Expression_Oracle extends Doctrine_Expression
|
||||
{
|
||||
/**
|
||||
* Returns a series of strings concatinated
|
||||
*
|
||||
@ -40,7 +41,8 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression {
|
||||
* @param string $arg1, $arg2 ... $argN strings that will be concatinated.
|
||||
* @return string
|
||||
*/
|
||||
public function concat($arg1, $arg2) {
|
||||
public function concat($arg1, $arg2)
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
$cols = $this->getIdentifiers( $args );
|
||||
@ -56,7 +58,8 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression {
|
||||
* @param integer $length the substring portion length
|
||||
* @return string SQL substring function with given parameters
|
||||
*/
|
||||
public function substring($value, $position, $length = null) {
|
||||
public function substring($value, $position, $length = null)
|
||||
{
|
||||
if ($length !== null)
|
||||
return "SUBSTR($value, $position, $length)";
|
||||
|
||||
@ -71,7 +74,8 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression {
|
||||
*
|
||||
* @return string to call a variable with the current timestamp
|
||||
*/
|
||||
public function now($type = 'timestamp') {
|
||||
public function now($type = 'timestamp')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'date':
|
||||
case 'time':
|
||||
@ -85,7 +89,8 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression {
|
||||
*
|
||||
* @return string an oracle SQL string that generates a float between 0 and 1
|
||||
*/
|
||||
function random() {
|
||||
function random()
|
||||
{
|
||||
return 'dbms_random.value';
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Expression');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Expression_Pgsql extends Doctrine_Expression {
|
||||
class Doctrine_Expression_Pgsql extends Doctrine_Expression
|
||||
{
|
||||
/**
|
||||
* Returns the md5 sum of a field.
|
||||
*
|
||||
@ -49,7 +50,8 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function md5($column) {
|
||||
public function md5($column)
|
||||
{
|
||||
$column = $this->getIdentifier($column);
|
||||
|
||||
if ($this->version > 7) {
|
||||
@ -69,7 +71,8 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression {
|
||||
* @param int $len extract this amount of characters.
|
||||
* @return string sql that extracts part of a string.
|
||||
*/
|
||||
public function substring($value, $from, $len = null) {
|
||||
public function substring($value, $from, $len = null)
|
||||
{
|
||||
$value = $this->getIdentifier($value);
|
||||
|
||||
if ($len === null) {
|
||||
@ -89,7 +92,8 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression {
|
||||
* @param string|array(string) strings that will be concatinated.
|
||||
* @return string
|
||||
*/
|
||||
public function concat($arg1, $arg2) {
|
||||
public function concat($arg1, $arg2)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$cols = $this->getIdentifiers($cols);
|
||||
|
||||
@ -100,7 +104,8 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression {
|
||||
*
|
||||
* @return string the regular expression operator
|
||||
*/
|
||||
public function regexp() {
|
||||
public function regexp()
|
||||
{
|
||||
return 'SIMILAR TO';
|
||||
}
|
||||
/**
|
||||
@ -109,7 +114,8 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression {
|
||||
* @return return string to generate float between 0 and 1
|
||||
* @access public
|
||||
*/
|
||||
public function random() {
|
||||
public function random()
|
||||
{
|
||||
return 'RANDOM()';
|
||||
}
|
||||
/**
|
||||
@ -129,7 +135,8 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression {
|
||||
*
|
||||
* @return string SQL pattern
|
||||
*/
|
||||
public function matchPattern($pattern, $operator = null, $field = null) {
|
||||
public function matchPattern($pattern, $operator = null, $field = null)
|
||||
{
|
||||
$match = '';
|
||||
if (!is_null($operator)) {
|
||||
$field = is_null($field) ? '' : $field.' ';
|
||||
|
@ -30,14 +30,16 @@ Doctrine::autoload('Doctrine_Expression');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Expression_Sqlite extends Doctrine_Expression {
|
||||
class Doctrine_Expression_Sqlite extends Doctrine_Expression
|
||||
{
|
||||
/**
|
||||
* Returns the md5 sum of the data that SQLite's md5() function receives.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return string
|
||||
*/
|
||||
public static function md5Impl($data) {
|
||||
public static function md5Impl($data)
|
||||
{
|
||||
return md5($data);
|
||||
}
|
||||
/**
|
||||
@ -47,7 +49,8 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
|
||||
* @param integer $divisor
|
||||
* @return string
|
||||
*/
|
||||
public static function modImpl($dividend, $divisor) {
|
||||
public static function modImpl($dividend, $divisor)
|
||||
{
|
||||
return $dividend % $divisor;
|
||||
}
|
||||
|
||||
@ -56,7 +59,8 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function concatImpl() {
|
||||
public static function concatImpl()
|
||||
{
|
||||
$args = func_get_args();
|
||||
return join( '', $args );
|
||||
}
|
||||
@ -69,19 +73,24 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
|
||||
* @param string $str literal string
|
||||
* @return string
|
||||
*/
|
||||
public static function locateImpl($substr, $str) {
|
||||
public static function locateImpl($substr, $str)
|
||||
{
|
||||
return strpos($str, $substr);
|
||||
}
|
||||
public static function sha1Impl($str) {
|
||||
public static function sha1Impl($str)
|
||||
{
|
||||
return sha1($str);
|
||||
}
|
||||
public static function ltrimImpl($str) {
|
||||
public static function ltrimImpl($str)
|
||||
{
|
||||
return ltrim($str);
|
||||
}
|
||||
public static function rtrimImpl($str) {
|
||||
public static function rtrimImpl($str)
|
||||
{
|
||||
return rtrim($str);
|
||||
}
|
||||
public static function trimImpl($str) {
|
||||
public static function trimImpl($str)
|
||||
{
|
||||
return trim($str);
|
||||
}
|
||||
/**
|
||||
@ -89,7 +98,8 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function regexp() {
|
||||
public function regexp()
|
||||
{
|
||||
return 'RLIKE';
|
||||
}
|
||||
/**
|
||||
@ -102,7 +112,8 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
|
||||
* @param string $value
|
||||
* @return string SQL soundex function with given parameter
|
||||
*/
|
||||
public function soundex($value) {
|
||||
public function soundex($value)
|
||||
{
|
||||
return 'SOUNDEX(' . $value . ')';
|
||||
}
|
||||
/**
|
||||
@ -111,7 +122,8 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
|
||||
*
|
||||
* @return string sqlite function as string
|
||||
*/
|
||||
public function now($type = 'timestamp') {
|
||||
public function now($type = 'timestamp')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'time':
|
||||
return 'time(\'now\')';
|
||||
@ -127,7 +139,8 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
|
||||
*
|
||||
* @return string to generate float between 0 and 1
|
||||
*/
|
||||
public function random() {
|
||||
public function random()
|
||||
{
|
||||
return '((RANDOM() + 2147483648) / 4294967296)';
|
||||
}
|
||||
/**
|
||||
@ -142,7 +155,8 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
|
||||
* @param integer $length the substring portion length
|
||||
* @return string SQL substring function with given parameters
|
||||
*/
|
||||
public function substring($value, $position, $length = null) {
|
||||
public function substring($value, $position, $length = null)
|
||||
{
|
||||
if ($length !== null) {
|
||||
return 'SUBSTR(' . $value . ', ' . $position . ', ' . $length . ')';
|
||||
}
|
||||
|
@ -30,7 +30,8 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Hook {
|
||||
class Doctrine_Hook
|
||||
{
|
||||
/**
|
||||
* @var Doctrine_Query $query the base query
|
||||
*/
|
||||
@ -69,7 +70,8 @@ class Doctrine_Hook {
|
||||
/**
|
||||
* @param Doctrine_Query $query the base query
|
||||
*/
|
||||
public function __construct($query) {
|
||||
public function __construct($query)
|
||||
{
|
||||
if (is_string($query)) {
|
||||
$this->query = new Doctrine_Query();
|
||||
$this->query->parseQuery($query);
|
||||
@ -77,13 +79,16 @@ class Doctrine_Hook {
|
||||
$this->query = $query;
|
||||
}
|
||||
}
|
||||
public function getQuery() {
|
||||
public function getQuery()
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
public function leftJoin($dql) {
|
||||
public function leftJoin($dql)
|
||||
{
|
||||
|
||||
}
|
||||
public function innerJoin($dql) {
|
||||
public function innerJoin($dql)
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
@ -94,7 +99,8 @@ class Doctrine_Hook {
|
||||
* names and their values
|
||||
* @return boolean whether or not the hooking was
|
||||
*/
|
||||
public function hookWhere($params) {
|
||||
public function hookWhere($params)
|
||||
{
|
||||
if ( ! is_array($params)) {
|
||||
return false;
|
||||
}
|
||||
@ -132,7 +138,8 @@ class Doctrine_Hook {
|
||||
* should be ordered by
|
||||
* @return boolean whether or not the hooking was
|
||||
*/
|
||||
public function hookOrderby($params) {
|
||||
public function hookOrderby($params)
|
||||
{
|
||||
if ( ! is_array($params)) {
|
||||
return false;
|
||||
}
|
||||
@ -162,13 +169,15 @@ class Doctrine_Hook {
|
||||
/**
|
||||
* @param integer $limit
|
||||
*/
|
||||
public function hookLimit($limit) {
|
||||
public function hookLimit($limit)
|
||||
{
|
||||
$this->query->limit((int) $limit);
|
||||
}
|
||||
/**
|
||||
* @param integer $offset
|
||||
*/
|
||||
public function hookOffset($offset) {
|
||||
public function hookOffset($offset)
|
||||
{
|
||||
$this->query->offset((int) $offset);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Hook_Parser');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Hook_Equal extends Doctrine_Hook_Parser {
|
||||
class Doctrine_Hook_Equal extends Doctrine_Hook_Parser
|
||||
{
|
||||
/**
|
||||
* parse
|
||||
* Parses given field and field value to DQL condition
|
||||
@ -43,7 +44,8 @@ class Doctrine_Hook_Equal extends Doctrine_Hook_Parser {
|
||||
* @param mixed $value the value of the field
|
||||
* @return void
|
||||
*/
|
||||
public function parse($alias, $field, $value) {
|
||||
public function parse($alias, $field, $value)
|
||||
{
|
||||
$this->params = (array) $value;
|
||||
$this->condition = $alias . '.' . $field . ' = ?';
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Hook_Parser_Complex');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Hook_Integer extends Doctrine_Hook_Parser_Complex {
|
||||
class Doctrine_Hook_Integer extends Doctrine_Hook_Parser_Complex
|
||||
{
|
||||
/**
|
||||
* parse
|
||||
* Parses given field and field value to DQL condition
|
||||
@ -43,7 +44,8 @@ class Doctrine_Hook_Integer extends Doctrine_Hook_Parser_Complex {
|
||||
* @param mixed $value the value of the field
|
||||
* @return void
|
||||
*/
|
||||
public function parseSingle($alias, $field, $value) {
|
||||
public function parseSingle($alias, $field, $value)
|
||||
{
|
||||
$e = explode(' ', $value);
|
||||
|
||||
foreach ($e as $v) {
|
||||
|
@ -30,15 +30,18 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
abstract class Doctrine_Hook_Parser {
|
||||
abstract class Doctrine_Hook_Parser
|
||||
{
|
||||
protected $condition;
|
||||
protected $params = array();
|
||||
|
||||
public function getCondition() {
|
||||
public function getCondition()
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
|
||||
public function getParams() {
|
||||
public function getParams()
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
/**
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Hook_Parser');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
abstract class Doctrine_Hook_Parser_Complex extends Doctrine_Hook_Parser {
|
||||
abstract class Doctrine_Hook_Parser_Complex extends Doctrine_Hook_Parser
|
||||
{
|
||||
/**
|
||||
* parse
|
||||
* Parses given field and field value to DQL condition
|
||||
@ -43,7 +44,8 @@ abstract class Doctrine_Hook_Parser_Complex extends Doctrine_Hook_Parser {
|
||||
* @param mixed $value the value of the field
|
||||
* @return void
|
||||
*/
|
||||
public function parse($alias, $field, $value) {
|
||||
public function parse($alias, $field, $value)
|
||||
{
|
||||
$this->condition = $this->parseClause($alias, $field, $value);
|
||||
}
|
||||
/**
|
||||
@ -54,7 +56,8 @@ abstract class Doctrine_Hook_Parser_Complex extends Doctrine_Hook_Parser {
|
||||
* @param mixed $value the value of the field
|
||||
* @return void
|
||||
*/
|
||||
public function parseClause($alias, $field, $value) {
|
||||
public function parseClause($alias, $field, $value)
|
||||
{
|
||||
$parts = Doctrine_Query::bracketExplode($value, ' AND ', '(', ')');
|
||||
|
||||
if (count($parts) > 1) {
|
||||
|
@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Hook_Parser');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Hook_WordLike extends Doctrine_Hook_Parser_Complex {
|
||||
class Doctrine_Hook_WordLike extends Doctrine_Hook_Parser_Complex
|
||||
{
|
||||
/**
|
||||
* parse
|
||||
* Parses given field and field value to DQL condition
|
||||
@ -43,7 +44,8 @@ class Doctrine_Hook_WordLike extends Doctrine_Hook_Parser_Complex {
|
||||
* @param mixed $value the value of the field
|
||||
* @return void
|
||||
*/
|
||||
public function parseSingle($alias, $field, $value) {
|
||||
public function parseSingle($alias, $field, $value)
|
||||
{
|
||||
$e2 = explode(' ',$value);
|
||||
|
||||
foreach ($e2 as $v) {
|
||||
|
@ -32,7 +32,8 @@ Doctrine::autoload('Doctrine_Access');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
abstract class Doctrine_Hydrate extends Doctrine_Access
|
||||
{
|
||||
/**
|
||||
* @var array $fetchmodes an array containing all fetchmodes
|
||||
*/
|
||||
@ -110,7 +111,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @param Doctrine_Connection|null $connection
|
||||
*/
|
||||
public function __construct($connection = null) {
|
||||
public function __construct($connection = null)
|
||||
{
|
||||
if ( ! ($connection instanceof Doctrine_Connection)) {
|
||||
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
|
||||
}
|
||||
@ -122,7 +124,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getComponentAliases() {
|
||||
public function getComponentAliases()
|
||||
{
|
||||
return $this->compAliases;
|
||||
}
|
||||
/**
|
||||
@ -130,7 +133,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTableAliases() {
|
||||
public function getTableAliases()
|
||||
{
|
||||
return $this->tableAliases;
|
||||
}
|
||||
/**
|
||||
@ -138,7 +142,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTableIndexes() {
|
||||
public function getTableIndexes()
|
||||
{
|
||||
return $this->tableIndexes;
|
||||
}
|
||||
/**
|
||||
@ -146,7 +151,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTables() {
|
||||
public function getTables()
|
||||
{
|
||||
return $this->tables;
|
||||
}
|
||||
/**
|
||||
@ -154,7 +160,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function copyAliases(Doctrine_Hydrate $query) {
|
||||
public function copyAliases(Doctrine_Hydrate $query)
|
||||
{
|
||||
$this->compAliases = $query->getComponentAliases();
|
||||
$this->tableAliases = $query->getTableAliases();
|
||||
$this->tableIndexes = $query->getTableIndexes();
|
||||
@ -162,7 +169,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPathAlias($path) {
|
||||
public function getPathAlias($path)
|
||||
{
|
||||
$s = array_search($path, $this->compAliases);
|
||||
if ($s === false)
|
||||
return $path;
|
||||
@ -174,7 +182,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return Doctrine_Hydrate
|
||||
*/
|
||||
public function createSubquery() {
|
||||
public function createSubquery()
|
||||
{
|
||||
$class = get_class($this);
|
||||
$obj = new $class();
|
||||
|
||||
@ -194,7 +203,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLimitSubqueryUsed() {
|
||||
public function isLimitSubqueryUsed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -203,7 +213,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @param $name
|
||||
*/
|
||||
public function remove($name) {
|
||||
public function remove($name)
|
||||
{
|
||||
if (isset($this->parts[$name])) {
|
||||
if ($name == "limit" || $name == "offset") {
|
||||
$this->parts[$name] = false;
|
||||
@ -219,7 +230,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function clear() {
|
||||
protected function clear()
|
||||
{
|
||||
$this->fetchModes = array();
|
||||
$this->tables = array();
|
||||
$this->parts = array(
|
||||
@ -247,7 +259,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return Doctrine_Connection
|
||||
*/
|
||||
public function getConnection() {
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->conn;
|
||||
}
|
||||
/**
|
||||
@ -258,7 +271,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
* @param Doctrine_View $view database view
|
||||
* @return void
|
||||
*/
|
||||
public function setView(Doctrine_View $view) {
|
||||
public function setView(Doctrine_View $view)
|
||||
{
|
||||
$this->view = $view;
|
||||
}
|
||||
/**
|
||||
@ -267,7 +281,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return Doctrine_View the view associated with this query object
|
||||
*/
|
||||
public function getView() {
|
||||
public function getView()
|
||||
{
|
||||
return $this->view;
|
||||
}
|
||||
/**
|
||||
@ -275,7 +290,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParams() {
|
||||
public function getParams()
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
/**
|
||||
@ -284,7 +300,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
final public function getTableAlias($path) {
|
||||
final public function getTableAlias($path)
|
||||
{
|
||||
if (isset($this->compAliases[$path])) {
|
||||
$path = $this->compAliases[$path];
|
||||
}
|
||||
@ -299,7 +316,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
* @parma string $name component name
|
||||
* @param integer $index
|
||||
*/
|
||||
private function getCollection($name) {
|
||||
private function getCollection($name)
|
||||
{
|
||||
$table = $this->tables[$name];
|
||||
if ( ! isset($this->fetchModes[$name])) {
|
||||
return new Doctrine_Collection($table);
|
||||
@ -333,7 +351,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
* @param mixed $item
|
||||
* @return void
|
||||
*/
|
||||
public static function convertBoolean(&$item) {
|
||||
public static function convertBoolean(&$item)
|
||||
{
|
||||
if (is_bool($item)) {
|
||||
$item = (int) $item;
|
||||
}
|
||||
@ -512,7 +531,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function initRelated(array $prev, $name) {
|
||||
public function initRelated(array $prev, $name)
|
||||
{
|
||||
$pointer = $this->joins[$name];
|
||||
$path = array_search($name, $this->tableAliases);
|
||||
$tmp = explode('.', $path);
|
||||
@ -543,7 +563,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function addRelated(array $prev, $name, Doctrine_Record $record) {
|
||||
public function addRelated(array $prev, $name, Doctrine_Record $record)
|
||||
{
|
||||
$pointer = $this->joins[$name];
|
||||
|
||||
$path = array_search($name, $this->tableAliases);
|
||||
@ -581,7 +602,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
* @param mixed $ids
|
||||
* @return boolean
|
||||
*/
|
||||
public function isIdentifiable(array $row, $ids) {
|
||||
public function isIdentifiable(array $row, $ids)
|
||||
{
|
||||
if (is_array($ids)) {
|
||||
foreach ($ids as $id) {
|
||||
if ($row[$id] == null)
|
||||
@ -600,7 +622,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyInheritance() {
|
||||
public function applyInheritance()
|
||||
{
|
||||
// get the inheritance maps
|
||||
$array = array();
|
||||
|
||||
@ -647,7 +670,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
* @param PDOStatement $stmt
|
||||
* @return array
|
||||
*/
|
||||
public function parseData(PDOStatement $stmt) {
|
||||
public function parseData(PDOStatement $stmt)
|
||||
{
|
||||
$array = array();
|
||||
|
||||
while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
@ -676,7 +700,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
* @param string $name component name
|
||||
* @return Doctrine_Table|boolean
|
||||
*/
|
||||
public function getTable($name) {
|
||||
public function getTable($name)
|
||||
{
|
||||
if (isset($this->tables[$name])) {
|
||||
return $this->tables[$name];
|
||||
}
|
||||
@ -685,7 +710,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
||||
/**
|
||||
* @return string returns a string representation of this object
|
||||
*/
|
||||
public function __toString() {
|
||||
public function __toString()
|
||||
{
|
||||
return Doctrine_Lib::formatSql($this->getQuery());
|
||||
}
|
||||
}
|
||||
|
@ -30,18 +30,21 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Hydrate_Alias {
|
||||
class Doctrine_Hydrate_Alias
|
||||
{
|
||||
|
||||
protected $shortAliases = array();
|
||||
|
||||
protected $shortAliasIndexes = array();
|
||||
|
||||
public function clear() {
|
||||
public function clear()
|
||||
{
|
||||
$this->shortAliases = array();
|
||||
$this->shortAliasIndexes = array();
|
||||
}
|
||||
|
||||
public function generateNewAlias($alias) {
|
||||
public function generateNewAlias($alias)
|
||||
{
|
||||
if (isset($this->shortAliases[$alias])) {
|
||||
// generate a new alias
|
||||
$name = substr($alias, 0, 1);
|
||||
@ -58,16 +61,19 @@ class Doctrine_Hydrate_Alias {
|
||||
return $alias;
|
||||
}
|
||||
|
||||
public function hasAliasFor($tableName) {
|
||||
public function hasAliasFor($tableName)
|
||||
{
|
||||
return (isset($this->shortAliases[$tableName]));
|
||||
}
|
||||
public function getShortAliasIndex($alias) {
|
||||
public function getShortAliasIndex($alias)
|
||||
{
|
||||
if ( ! isset($this->shortAliasIndexes[$alias])) {
|
||||
return 0;
|
||||
}
|
||||
return $this->shortAliasIndexes[$alias];
|
||||
}
|
||||
public function generateShortAlias($tableName) {
|
||||
public function generateShortAlias($tableName)
|
||||
{
|
||||
$char = strtolower(substr($tableName, 0, 1));
|
||||
|
||||
$alias = $char;
|
||||
@ -83,7 +89,8 @@ class Doctrine_Hydrate_Alias {
|
||||
return $alias;
|
||||
}
|
||||
|
||||
public function getShortAlias($tableName) {
|
||||
public function getShortAlias($tableName)
|
||||
{
|
||||
$alias = array_search($tableName, $this->shortAliases);
|
||||
|
||||
if ($alias !== false) {
|
||||
|
@ -29,7 +29,8 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Identifier {
|
||||
class Doctrine_Identifier
|
||||
{
|
||||
/**
|
||||
* constant for auto_increment identifier
|
||||
*/
|
||||
|
@ -33,7 +33,8 @@
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
* @author Jukka Hassinen <Jukka.Hassinen@BrainAlliance.com>
|
||||
*/
|
||||
class Doctrine_Import_Builder {
|
||||
class Doctrine_Import_Builder
|
||||
{
|
||||
|
||||
private $path = '';
|
||||
|
||||
@ -41,7 +42,8 @@ class Doctrine_Import_Builder {
|
||||
|
||||
private static $tpl;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
if ( ! isset(self::$tpl)) {
|
||||
self::$tpl = file_get_contents(Doctrine::getPath()
|
||||
. DIRECTORY_SEPARATOR . 'Doctrine'
|
||||
@ -57,14 +59,16 @@ class Doctrine_Import_Builder {
|
||||
* @return
|
||||
* @access public
|
||||
*/
|
||||
public function setTargetPath($path) {
|
||||
public function setTargetPath($path)
|
||||
{
|
||||
if ( ! file_exists($path)) {
|
||||
mkdir($path, 0777);
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
}
|
||||
public function getTargetPath() {
|
||||
public function getTargetPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
/**
|
||||
@ -73,14 +77,17 @@ class Doctrine_Import_Builder {
|
||||
* @return
|
||||
* @access public
|
||||
*/
|
||||
public function setFileSuffix($suffix) {
|
||||
public function setFileSuffix($suffix)
|
||||
{
|
||||
$this->suffix = $suffix;
|
||||
}
|
||||
public function getFileSuffix() {
|
||||
public function getFileSuffix()
|
||||
{
|
||||
return $this->suffix;
|
||||
}
|
||||
|
||||
public function buildRecord(Doctrine_Schema_Table $table) {
|
||||
public function buildRecord(Doctrine_Schema_Table $table)
|
||||
{
|
||||
if (empty($this->path)) {
|
||||
throw new Doctrine_Import_Builder_Exception('No build target directory set.');
|
||||
}
|
||||
@ -146,7 +153,8 @@ class Doctrine_Import_Builder {
|
||||
* @throws Doctrine_Import_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function build(Doctrine_Schema_Object $schema) {
|
||||
public function build(Doctrine_Schema_Object $schema)
|
||||
{
|
||||
foreach ($schema->getDatabases() as $database){
|
||||
foreach ($database->getTables() as $table){
|
||||
$this->buildRecord($table);
|
||||
|
@ -37,5 +37,6 @@ Doctrine::autoload('Doctrine_Import_Builder');
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_Import_Builder_BaseClass extends Doctrine_Import_Builder {
|
||||
class Doctrine_Import_Builder_BaseClass extends Doctrine_Import_Builder
|
||||
{
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user