Commit 716bb65b authored by lsmith's avatar lsmith

- first round of PEAR CS fixes

parent f6400e01
This diff is collapsed.
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This software consists of voluntary contributions made by many individuals * This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>. * <http://www.phpdoctrine.com>.
*/ */
/** /**
* Doctrine_Access * Doctrine_Access
* *
* the purpose of Doctrine_Access is to provice array access * the purpose of Doctrine_Access is to provice array access
* and property overload interface for subclasses * and property overload interface for subclasses
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
abstract class Doctrine_Access implements ArrayAccess { abstract class Doctrine_Access implements ArrayAccess {
/** /**
* setArray * setArray
* *
* @param array $array an array of key => value pairs * @param array $array an array of key => value pairs
* @since 1.0 * @since 1.0
* @return Doctrine_Access * @return Doctrine_Access
*/ */
public function setArray(array $array) { public function setArray(array $array) {
foreach($array as $k=>$v): foreach ($array as $k=>$v) {
$this->set($k,$v); $this->set($k,$v);
endforeach; };
return $this; return $this;
} }
/** /**
* __set an alias of set() * __set an alias of set()
* *
* @see set, offsetSet * @see set, offsetSet
* @param $name * @param $name
* @param $value * @param $value
* @since 1.0 * @since 1.0
* @return void * @return void
*/ */
public function __set($name,$value) { public function __set($name,$value) {
$this->set($name,$value); $this->set($name,$value);
} }
/** /**
* __get -- an alias of get() * __get -- an alias of get()
* *
* @see get, offsetGet * @see get, offsetGet
* @param mixed $name * @param mixed $name
* @since 1.0 * @since 1.0
* @return mixed * @return mixed
*/ */
public function __get($name) { public function __get($name) {
return $this->get($name); return $this->get($name);
} }
/** /**
* __isset() * __isset()
* *
* @param string $name * @param string $name
* @since 1.0 * @since 1.0
* @return boolean whether or not this object contains $name * @return boolean whether or not this object contains $name
*/ */
public function __isset($name) { public function __isset($name) {
return $this->contains($name); return $this->contains($name);
} }
/** /**
* __unset() * __unset()
* *
* @param string $name * @param string $name
* @since 1.0 * @since 1.0
* @return void * @return void
*/ */
public function __unset($name) { public function __unset($name) {
return $this->remove($name); return $this->remove($name);
} }
/** /**
* @param mixed $offset * @param mixed $offset
* @return boolean whether or not this object contains $offset * @return boolean whether or not this object contains $offset
*/ */
public function offsetExists($offset) { public function offsetExists($offset) {
return $this->contains($offset); return $this->contains($offset);
} }
/** /**
* offsetGet an alias of get() * offsetGet an alias of get()
* @see get, __get * @see get, __get
* @param mixed $offset * @param mixed $offset
* @return mixed * @return mixed
*/ */
public function offsetGet($offset) { public function offsetGet($offset) {
return $this->get($offset); return $this->get($offset);
} }
/** /**
* sets $offset to $value * sets $offset to $value
* @see set, __set * @see set, __set
* @param mixed $offset * @param mixed $offset
* @param mixed $value * @param mixed $value
* @return void * @return void
*/ */
public function offsetSet($offset, $value) { public function offsetSet($offset, $value) {
if( ! isset($offset)) { if ( ! isset($offset)) {
$this->add($value); $this->add($value);
} else } else {
$this->set($offset,$value); $this->set($offset,$value);
} }
/** }
* unset a given offset /**
* @see set, offsetSet, __set * unset a given offset
* @param mixed $offset * @see set, offsetSet, __set
*/ * @param mixed $offset
public function offsetUnset($offset) { */
return $this->remove($offset); public function offsetUnset($offset) {
} return $this->remove($offset);
} }
}
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.phpdoctrine.com>. * <http://www.phpdoctrine.com>.
*/ */
/** /**
* *
* Doctrine_Adapter * Doctrine_Adapter
* *
* @package Doctrine * @package Doctrine
...@@ -92,7 +92,7 @@ class Doctrine_Adapter { ...@@ -92,7 +92,7 @@ class Doctrine_Adapter {
const FETCH_UNIQUE = 196608; const FETCH_UNIQUE = 196608;
const NULL_EMPTY_STRING = 1; const NULL_EMPTY_STRING = 1;
const NULL_NATURAL = 0; const NULL_NATURAL = 0;
const NULL_TO_STRING = NULL; const NULL_TO_STRING = NULL;
const PARAM_BOOL = 5; const PARAM_BOOL = 5;
const PARAM_INPUT_OUTPUT = -2147483648; const PARAM_INPUT_OUTPUT = -2147483648;
const PARAM_INT = 1; const PARAM_INT = 1;
......
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,14 @@
/** /**
* Doctrine_Adapter_Statement * Doctrine_Adapter_Statement
* *
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine * @package Doctrine
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
*/ */
abstract class Doctrine_Adapter_Statement { abstract class Doctrine_Adapter_Statement {
public function bindValue($no, $value) { public function bindValue($no, $value) {
} }
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -49,19 +49,17 @@ class Doctrine_Cache_Query_Sqlite implements Countable { ...@@ -49,19 +49,17 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
* @param Doctrine_Connection|null $connection * @param Doctrine_Connection|null $connection
*/ */
public function __construct($connection = null) { public function __construct($connection = null) {
if( ! ($connection instanceof Doctrine_Connection)) if ( ! ($connection instanceof Doctrine_Connection)) {
$connection = Doctrine_Manager::getInstance()->getCurrentConnection(); $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
}
$this->session = $connection; $this->session = $connection;
$dir = 'cache'; $dir = 'cache';
$this->path = $dir.DIRECTORY_SEPARATOR; $this->path = $dir.DIRECTORY_SEPARATOR;
$this->dbh = new PDO("sqlite::memory:"); $this->dbh = new PDO("sqlite::memory:");
try { try {
if($this->session->getAttribute(Doctrine::ATTR_CREATE_TABLES) === true) if ($this->session->getAttribute(Doctrine::ATTR_CREATE_TABLES) === true) {
{
$columns = array(); $columns = array();
$columns['query_md5'] = array('string', 32, 'notnull'); $columns['query_md5'] = array('string', 32, 'notnull');
$columns['query_result'] = array('array', 100000, 'notnull'); $columns['query_result'] = array('array', 100000, 'notnull');
...@@ -127,7 +125,7 @@ class Doctrine_Cache_Query_Sqlite implements Countable { ...@@ -127,7 +125,7 @@ class Doctrine_Cache_Query_Sqlite implements Countable {
} }
/** /**
* delete * delete
* returns whether or not the given * returns whether or not the given
* query was succesfully deleted * query was succesfully deleted
* *
* @param string $md5 * @param string $md5
......
This diff is collapsed.
...@@ -24,14 +24,14 @@ Doctrine::autoload('Doctrine_Collection'); ...@@ -24,14 +24,14 @@ Doctrine::autoload('Doctrine_Collection');
* with batch load strategy * with batch load strategy
* *
* *
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision$ * @version $Revision$
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
*/ */
class Doctrine_Collection_Batch extends Doctrine_Collection { class Doctrine_Collection_Batch extends Doctrine_Collection {
/** /**
* @var integer $batchSize batch size * @var integer $batchSize batch size
...@@ -41,7 +41,7 @@ class Doctrine_Collection_Batch extends Doctrine_Collection { ...@@ -41,7 +41,7 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
* @var array $loaded an array containing the loaded batches, keys representing the batch indexes * @var array $loaded an array containing the loaded batches, keys representing the batch indexes
*/ */
private $loaded = array(); private $loaded = array();
public function __construct(Doctrine_Table $table) { public function __construct(Doctrine_Table $table) {
parent::__construct($table); parent::__construct($table);
$this->batchSize = $this->getTable()->getAttribute(Doctrine::ATTR_BATCH_SIZE); $this->batchSize = $this->getTable()->getAttribute(Doctrine::ATTR_BATCH_SIZE);
...@@ -53,9 +53,9 @@ class Doctrine_Collection_Batch extends Doctrine_Collection { ...@@ -53,9 +53,9 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
*/ */
public function setBatchSize($batchSize) { public function setBatchSize($batchSize) {
$batchSize = (int) $batchSize; $batchSize = (int) $batchSize;
if($batchSize <= 0) if ($batchSize <= 0) {
return false; return false;
}
$this->batchSize = $batchSize; $this->batchSize = $batchSize;
return true; return true;
} }
...@@ -68,47 +68,46 @@ class Doctrine_Collection_Batch extends Doctrine_Collection { ...@@ -68,47 +68,46 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
return $this->batchSize; return $this->batchSize;
} }
/** /**
* load * load
* loads a specified element, by loading the batch the element is part of * loads a specified element, by loading the batch the element is part of
* *
* @param Doctrine_Record $record record to be loaded * @param Doctrine_Record $record record to be loaded
* @return boolean whether or not the load operation was successful * @return boolean whether or not the load operation was successful
*/ */
public function load(Doctrine_Record $record) { public function load(Doctrine_Record $record) {
if(empty($this->data)) if (empty($this->data)) {
return false; return false;
}
$id = $record->obtainIdentifier(); $id = $record->obtainIdentifier();
$identifier = $this->table->getIdentifier(); $identifier = $this->table->getIdentifier();
foreach($this->data as $key => $v) { foreach ($this->data as $key => $v) {
if(is_object($v)) { if (is_object($v)) {
if($v->obtainIdentifier() == $id) if ($v->obtainIdentifier() == $id) {
break; break;
}
} elseif(is_array($v[$identifier])) { } elseif (is_array($v[$identifier])) {
if($v[$identifier] == $id) if ($v[$identifier] == $id) {
break; break;
}
} }
} }
$x = floor($key / $this->batchSize); $x = floor($key / $this->batchSize);
if( ! isset($this->loaded[$x])) { if ( ! isset($this->loaded[$x])) {
$e = $x * $this->batchSize; $e = $x * $this->batchSize;
$e2 = ($x + 1)* $this->batchSize; $e2 = ($x + 1)* $this->batchSize;
$a = array(); $a = array();
$proxies = array(); $proxies = array();
for($i = $e; $i < $e2 && $i < $this->count(); $i++): for ($i = $e; $i < $e2 && $i < $this->count(); $i++) {
if($this->data[$i] instanceof Doctrine_Record) if ($this->data[$i] instanceof Doctrine_Record) {
$id = $this->data[$i]->getIncremented(); $id = $this->data[$i]->getIncremented();
elseif(is_array($this->data[$i])) } elseif (is_array($this->data[$i])) {
$id = $this->data[$i][$identifier]; $id = $this->data[$i][$identifier];
}
$a[$i] = $id; $a[$i] = $id;
endfor; };
$c = count($a); $c = count($a);
...@@ -120,14 +119,14 @@ class Doctrine_Collection_Batch extends Doctrine_Collection { ...@@ -120,14 +119,14 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
$stmt = $this->table->getConnection()->execute($query,array_values($a)); $stmt = $this->table->getConnection()->execute($query,array_values($a));
foreach($a as $k => $id) { foreach ($a as $k => $id) {
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
if($row === false) if ($row === false) {
break; break;
}
$this->table->setData($row); $this->table->setData($row);
if(is_object($this->data[$k])) { if (is_object($this->data[$k])) {
$this->data[$k]->factoryRefresh($this->table); $this->data[$k]->factoryRefresh($this->table);
} else { } else {
$this->data[$k] = $this->table->getRecord(); $this->data[$k] = $this->table->getRecord();
...@@ -148,30 +147,27 @@ class Doctrine_Collection_Batch extends Doctrine_Collection { ...@@ -148,30 +147,27 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
* @return object Doctrine_Record record * @return object Doctrine_Record record
*/ */
public function get($key) { public function get($key) {
if(isset($this->data[$key])) { if (isset($this->data[$key])) {
switch(gettype($this->data[$key])): switch (gettype($this->data[$key])) {
case "array": case "array":
// Doctrine_Record didn't exist in cache // Doctrine_Record didn't exist in cache
$this->table->setData($this->data[$key]); $this->table->setData($this->data[$key]);
$this->data[$key] = $this->table->getProxy(); $this->data[$key] = $this->table->getProxy();
$this->data[$key]->addCollection($this); $this->data[$key]->addCollection($this);
break; break;
endswitch; };
} else { } else {
$this->expand($key); $this->expand($key);
if( ! isset($this->data[$key])) if ( ! isset($this->data[$key])) {
$this->data[$key] = $this->table->create(); $this->data[$key] = $this->table->create();
}
} }
if (isset($this->reference_field)) {
if(isset($this->reference_field))
$this->data[$key]->set($this->reference_field, $this->reference, false); $this->data[$key]->set($this->reference_field, $this->reference, false);
}
return $this->data[$key]; return $this->data[$key];
} }
/** /**
...@@ -181,4 +177,3 @@ class Doctrine_Collection_Batch extends Doctrine_Collection { ...@@ -181,4 +177,3 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
return new Doctrine_Collection_Iterator_Expandable($this); return new Doctrine_Collection_Iterator_Expandable($this);
} }
} }
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
/** /**
* Doctrine_Collection_Exception * Doctrine_Collection_Exception
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Collection_Exception extends Doctrine_Exception { } class Doctrine_Collection_Exception extends Doctrine_Exception { }
<?php <?php
Doctrine::autoload('Doctrine_Collection'); Doctrine::autoload('Doctrine_Collection');
/** /**
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision$ * @version $Revision$
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
*/ */
class Doctrine_Collection_Immediate extends Doctrine_Collection { class Doctrine_Collection_Immediate extends Doctrine_Collection {
/** /**
* @param Doctrine_DQL_Parser $graph * @param Doctrine_DQL_Parser $graph
* @param integer $key * @param integer $key
*/ */
public function __construct(Doctrine_Table $table) { public function __construct(Doctrine_Table $table) {
parent::__construct($table); parent::__construct($table);
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -22,17 +22,17 @@ ...@@ -22,17 +22,17 @@
* Doctrine_Collection_Iterator * Doctrine_Collection_Iterator
* iterates through Doctrine_Collection * iterates through Doctrine_Collection
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
abstract class Doctrine_Collection_Iterator implements Iterator { abstract class Doctrine_Collection_Iterator implements Iterator {
/** /**
* @var Doctrine_Collection $collection * @var Doctrine_Collection $collection
*/ */
protected $collection; protected $collection;
/** /**
...@@ -69,8 +69,9 @@ abstract class Doctrine_Collection_Iterator implements Iterator { ...@@ -69,8 +69,9 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
public function rewind() { public function rewind() {
$this->index = 0; $this->index = 0;
$i = $this->index; $i = $this->index;
if(isset($this->keys[$i])) if (isset($this->keys[$i])) {
$this->key = $this->keys[$i]; $this->key = $this->keys[$i];
}
} }
/** /**
...@@ -97,10 +98,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator { ...@@ -97,10 +98,8 @@ abstract class Doctrine_Collection_Iterator implements Iterator {
public function next() { public function next() {
$this->index++; $this->index++;
$i = $this->index; $i = $this->index;
if(isset($this->keys[$i])) if (isset($this->keys[$i])) {
$this->key = $this->keys[$i]; $this->key = $this->keys[$i];
}
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -22,25 +22,24 @@ Doctrine::autoload('Doctrine_Collection_Iterator'); ...@@ -22,25 +22,24 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
/** /**
* Doctrine_Collection_Iterator_Normal * Doctrine_Collection_Iterator_Normal
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterator { class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterator {
public function valid() { public function valid() {
if($this->index < $this->count) if ($this->index < $this->count) {
return true; return true;
elseif($this->index == $this->count) { } elseif ($this->index == $this->count) {
$coll = $this->collection->expand($this->index); $coll = $this->collection->expand($this->index);
if($coll instanceof Doctrine_Collection) { if ($coll instanceof Doctrine_Collection) {
$count = count($coll); $count = count($coll);
if($count > 0) { if ($count > 0) {
$this->keys = array_merge($this->keys, $coll->getKeys()); $this->keys = array_merge($this->keys, $coll->getKeys());
$this->count += $count; $this->count += $count;
return true; return true;
...@@ -51,4 +50,3 @@ class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterat ...@@ -51,4 +50,3 @@ class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterat
} }
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -22,14 +22,14 @@ Doctrine::autoload('Doctrine_Collection_Iterator'); ...@@ -22,14 +22,14 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
/** /**
* Doctrine_Collection_Iterator_Normal * Doctrine_Collection_Iterator_Normal
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator { class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator {
/** /**
* @return boolean whether or not the iteration will continue * @return boolean whether or not the iteration will continue
...@@ -38,4 +38,3 @@ class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator { ...@@ -38,4 +38,3 @@ class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator {
return ($this->index < $this->count); return ($this->index < $this->count);
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -22,16 +22,14 @@ Doctrine::autoload('Doctrine_Collection_Iterator'); ...@@ -22,16 +22,14 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
/** /**
* Doctrine_Collection_Iterator_Normal * Doctrine_Collection_Iterator_Normal
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Collection_Iterator_Offset extends Doctrine_Collection_Iterator { class Doctrine_Collection_Iterator_Offset extends Doctrine_Collection_Iterator {
public function valid() { } public function valid() { }
} }
<?php <?php
require_once("Batch.php"); require_once("Batch.php");
/** /**
* a collection of Doctrine_Record objects with lazy load strategy * a collection of Doctrine_Record objects with lazy load strategy
* (batch load strategy with batch size 1) * (batch load strategy with batch size 1)
* @package Doctrine * @package Doctrine
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Collection_Lazy extends Doctrine_Collection_Batch { class Doctrine_Collection_Lazy extends Doctrine_Collection_Batch {
/** /**
* constructor * constructor
* @param Doctrine_DQL_Parser $graph * @param Doctrine_DQL_Parser $graph
* @param string $key * @param string $key
*/ */
public function __construct(Doctrine_Table $table) { public function __construct(Doctrine_Table $table) {
...@@ -22,4 +22,3 @@ class Doctrine_Collection_Lazy extends Doctrine_Collection_Batch { ...@@ -22,4 +22,3 @@ class Doctrine_Collection_Lazy extends Doctrine_Collection_Batch {
parent::setBatchSize(1); parent::setBatchSize(1);
} }
} }
...@@ -23,14 +23,14 @@ Doctrine::autoload('Doctrine_Collection_Offset'); ...@@ -23,14 +23,14 @@ Doctrine::autoload('Doctrine_Collection_Offset');
* Doctrine_Collection_Offset * Doctrine_Collection_Offset
* Collection of Doctrine_Record objects. * Collection of Doctrine_Record objects.
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Collection_Offset extends Doctrine_Collection { class Doctrine_Collection_Offset extends Doctrine_Collection {
/** /**
* @var integer $limit * @var integer $limit
...@@ -56,4 +56,3 @@ class Doctrine_Collection_Offset extends Doctrine_Collection { ...@@ -56,4 +56,3 @@ class Doctrine_Collection_Offset extends Doctrine_Collection {
return new Doctrine_Collection_Iterator_Expandable($this); return new Doctrine_Collection_Iterator_Expandable($this);
} }
} }
This diff is collapsed.
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
/** /**
* Doctrine_Compiler_Exception * Doctrine_Compiler_Exception
* *
* @package Doctrine * @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
*/ */
class Doctrine_Compiler_Exception extends Doctrine_Exception { } class Doctrine_Compiler_Exception extends Doctrine_Exception { }
This diff is collapsed.
This diff is collapsed.
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
Doctrine::autoload('Doctrine_Connection'); Doctrine::autoload('Doctrine_Connection');
/** /**
* standard connection, the parent of pgsql, mysql and sqlite * standard connection, the parent of pgsql, mysql and sqlite
* @package Doctrine * @package Doctrine
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Connection_Common extends Doctrine_Connection { class Doctrine_Connection_Common extends Doctrine_Connection {
/** /**
* Adds an driver-specific LIMIT clause to the query * Adds an driver-specific LIMIT clause to the query
...@@ -19,15 +19,14 @@ class Doctrine_Connection_Common extends Doctrine_Connection { ...@@ -19,15 +19,14 @@ class Doctrine_Connection_Common extends Doctrine_Connection {
* @param mixed $offset * @param mixed $offset
*/ */
public function modifyLimitQuery($query,$limit = false,$offset = false,$isManip=false) { public function modifyLimitQuery($query,$limit = false,$offset = false,$isManip=false) {
if($limit && $offset) { if ($limit && $offset) {
$query .= " LIMIT ".$limit." OFFSET ".$offset; $query .= " LIMIT ".$limit." OFFSET ".$offset;
} elseif($limit && ! $offset) { } elseif ($limit && ! $offset) {
$query .= " LIMIT ".$limit; $query .= " LIMIT ".$limit;
} elseif( ! $limit && $offset) { } elseif ( ! $limit && $offset) {
$query .= " LIMIT 999999999999 OFFSET ".$offset; $query .= " LIMIT 999999999999 OFFSET ".$offset;
} }
return $query; return $query;
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -40,24 +40,23 @@ class Doctrine_Connection_Db2 extends Doctrine_Connection { ...@@ -40,24 +40,23 @@ class Doctrine_Connection_Db2 extends Doctrine_Connection {
* @return string the modified query * @return string the modified query
*/ */
public function modifyLimitQuery($query, $limit, $offset) { public function modifyLimitQuery($query, $limit, $offset) {
if($limit <= 0) if ($limit <= 0)
return $sql; return $sql;
if($offset == 0) { if ($offset == 0) {
return $sql . ' FETCH FIRST '. $count .' ROWS ONLY'; return $sql . ' FETCH FIRST '. $count .' ROWS ONLY';
} else { } else {
$sqlPieces = explode('from', $sql);
$sqlPieces = explode('from', $sql); $select = $sqlPieces[0];
$select = $sqlPieces[0]; $table = $sqlPieces[1];
$table = $sqlPieces[1];
$col = explode('select', $select);
$sql = 'WITH OFFSET AS(' . $select . ', ROW_NUMBER() ' . $col = explode('select', $select);
'OVER(ORDER BY ' . $col[1] . ') AS dctrn_rownum FROM ' . $table . ')' .
$select . 'FROM OFFSET WHERE dctrn_rownum BETWEEN ' . $offset . $sql = 'WITH OFFSET AS(' . $select . ', ROW_NUMBER() ' .
'AND ' . ($offset + $count - 1); 'OVER(ORDER BY ' . $col[1] . ') AS dctrn_rownum FROM ' . $table . ')' .
return $sql; $select . 'FROM OFFSET WHERE dctrn_rownum BETWEEN ' . $offset .
} 'AND ' . ($offset + $count - 1);
return $sql;
}
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_Exception'); ...@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_Exception');
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Connection_Exception extends Doctrine_Exception { class Doctrine_Connection_Exception extends Doctrine_Exception {
/** /**
* @var array $errorMessages an array containing messages for portable error codes * @var array $errorMessages an array containing messages for portable error codes
*/ */
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -95,7 +95,7 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection { ...@@ -95,7 +95,7 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
* @return string modified query * @return string modified query
*/ */
public function modifyLimitQuery($query, $limit, $offset) { public function modifyLimitQuery($query, $limit, $offset) {
if($limit > 0) { if ($limit > 0) {
$query = preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i', $query = preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i',
"SELECT FIRST $limit SKIP $offset", $query); "SELECT FIRST $limit SKIP $offset", $query);
} }
...@@ -112,4 +112,3 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection { ...@@ -112,4 +112,3 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
return $data[0]; return $data[0];
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -32,7 +32,7 @@ Doctrine::autoload('Doctrine_Connection_Exception'); ...@@ -32,7 +32,7 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver) * @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver)
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library) * @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
*/ */
class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Exception { class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Exception {
/** /**
* @var array $errorCodeMap an array that is used for determining portable * @var array $errorCodeMap an array that is used for determining portable
* error code from a native database error code * error code from a native database error code
...@@ -68,16 +68,16 @@ class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Excepti ...@@ -68,16 +68,16 @@ class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Excepti
-924 => Doctrine::ERR_CONNECT_FAILED -924 => Doctrine::ERR_CONNECT_FAILED
); );
/** /**
* @var array $errorRegexps an array that is used for determining portable * @var array $errorRegexps an array that is used for determining portable
* error code from a native database error message * error code from a native database error message
*/ */
protected static $errorRegexps = array( protected static $errorRegexps = array(
'/generator .* is not defined/' '/generator .* is not defined/'
=> Doctrine::ERR_SYNTAX, // for compat. w ibase_errcode() => Doctrine::ERR_SYNTAX, // for compat. w ibase_errcode()
'/table.*(not exist|not found|unknown)/i' '/table.*(not exist|not found|unknown)/i'
=> Doctrine::ERR_NOSUCHTABLE, => Doctrine::ERR_NOSUCHTABLE,
'/table .* already exists/i' '/table .* already exists/i'
=> Doctrine::ERR_ALREADY_EXISTS, => Doctrine::ERR_ALREADY_EXISTS,
'/unsuccessful metadata update .* failed attempt to store duplicate value/i' '/unsuccessful metadata update .* failed attempt to store duplicate value/i'
=> Doctrine::ERR_ALREADY_EXISTS, => Doctrine::ERR_ALREADY_EXISTS,
'/unsuccessful metadata update .* not found/i' '/unsuccessful metadata update .* not found/i'
...@@ -92,12 +92,12 @@ class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Excepti ...@@ -92,12 +92,12 @@ class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Excepti
=> Doctrine::ERR_ACCESS_VIOLATION, => Doctrine::ERR_ACCESS_VIOLATION,
'/arithmetic exception, numeric overflow, or string truncation/i' '/arithmetic exception, numeric overflow, or string truncation/i'
=> Doctrine::ERR_INVALID, => Doctrine::ERR_INVALID,
'/table unknown/i' '/table unknown/i'
=> Doctrine::ERR_NOSUCHTABLE, => Doctrine::ERR_NOSUCHTABLE,
); );
/** /**
* This method checks if native error code/message can be * This method checks if native error code/message can be
* converted into a portable code and then adds this * converted into a portable code and then adds this
* portable error code to errorInfo array and returns the modified array * portable error code to errorInfo array and returns the modified array
* *
* the portable error code is added at the end of array * the portable error code is added at the end of array
...@@ -118,15 +118,15 @@ class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Excepti ...@@ -118,15 +118,15 @@ class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Excepti
} }
*/ */
foreach(self::$errorRegexps as $regexp => $code) { foreach (self::$errorRegexps as $regexp => $code) {
if (preg_match($regexp, $errorInfo[2])) { if (preg_match($regexp, $errorInfo[2])) {
$errorInfo[3] = $code; $errorInfo[3] = $code;
break; break;
} }
} }
if(isset(self::$errorCodeMap[$errorInfo[1]])) if (isset(self::$errorCodeMap[$errorInfo[1]])) {
$errorInfo[3] = self::$errorCodeMap[$errorInfo[1]]; $errorInfo[3] = self::$errorCodeMap[$errorInfo[1]];
}
return $errorInfo; return $errorInfo;
} }
} }
...@@ -22,15 +22,15 @@ Doctrine::autoload('Doctrine_Connection'); ...@@ -22,15 +22,15 @@ Doctrine::autoload('Doctrine_Connection');
/** /**
* Doctrine_Connection_Mysql * Doctrine_Connection_Mysql
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Connection_Informix extends Doctrine_Connection { class Doctrine_Connection_Informix extends Doctrine_Connection {
/** /**
* @var string $driverName the name of this connection driver * @var string $driverName the name of this connection driver
*/ */
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_Connection_Exception'); ...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_Connection_Exception');
/** /**
* Doctrine_Connection_Informix_Exception * Doctrine_Connection_Informix_Exception
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Connection_Informix_Exception extends Doctrine_Connection_Exception { } class Doctrine_Connection_Informix_Exception extends Doctrine_Connection_Exception { }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
*/ */
class Doctrine_Connection_Module { class Doctrine_Connection_Module {
/** /**
* @var Doctrine_Connection $conn Doctrine_Connection object, every connection * @var Doctrine_Connection $conn Doctrine_Connection object, every connection
* module holds an instance of Doctrine_Connection * module holds an instance of Doctrine_Connection
*/ */
protected $conn; protected $conn;
...@@ -44,11 +44,11 @@ class Doctrine_Connection_Module { ...@@ -44,11 +44,11 @@ class Doctrine_Connection_Module {
* module holds an instance of Doctrine_Connection * module holds an instance of Doctrine_Connection
*/ */
public function __construct($conn = null) { public function __construct($conn = null) {
if( ! ($conn instanceof Doctrine_Connection)) if ( ! ($conn instanceof Doctrine_Connection)) {
$conn = Doctrine_Manager::getInstance()->getCurrentConnection(); $conn = Doctrine_Manager::getInstance()->getCurrentConnection();
}
$this->conn = $conn; $this->conn = $conn;
$e = explode('_', get_class($this)); $e = explode('_', get_class($this));
$this->moduleName = $e[1]; $this->moduleName = $e[1];
...@@ -69,6 +69,6 @@ class Doctrine_Connection_Module { ...@@ -69,6 +69,6 @@ class Doctrine_Connection_Module {
* @return string the name of this module * @return string the name of this module
*/ */
public function getModuleName() { public function getModuleName() {
return $this->moduleName; return $this->moduleName;
} }
} }
...@@ -104,13 +104,12 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection { ...@@ -104,13 +104,12 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
* @return string * @return string
*/ */
public function modifyLimitQuery($query, $limit, $offset, $isManip = false) { public function modifyLimitQuery($query, $limit, $offset, $isManip = false) {
if($limit > 0) { if ($limit > 0) {
// we need the starting SELECT clause for later // we need the starting SELECT clause for later
$select = 'SELECT '; $select = 'SELECT ';
if (preg_match('/^[[:space:]*SELECT[[:space:]]*DISTINCT/i', $query, $matches) == 1) if (preg_match('/^[[:space:]*SELECT[[:space:]]*DISTINCT/i', $query, $matches) == 1) {
$select .= 'DISTINCT '; $select .= 'DISTINCT ';
}
$length = strlen($select); $length = strlen($select);
// is there an offset? // is there an offset?
...@@ -168,4 +167,3 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection { ...@@ -168,4 +167,3 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
return $this->queryOne($query); return $this->queryOne($query);
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Connection_Exception'); ...@@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
*/ */
class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception { class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception {
/** /**
* @var array $errorCodeMap an array that is used for determining portable * @var array $errorCodeMap an array that is used for determining portable
* error code from a native database error code * error code from a native database error code
...@@ -53,7 +53,7 @@ class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception ...@@ -53,7 +53,7 @@ class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception
); );
/** /**
* This method checks if native error code/message can be * This method checks if native error code/message can be
* converted into a portable code and then adds this * converted into a portable code and then adds this
* portable error code to $portableCode field * portable error code to $portableCode field
* *
* @param array $errorInfo error info array * @param array $errorInfo error info array
...@@ -63,7 +63,7 @@ class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception ...@@ -63,7 +63,7 @@ class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception
*/ */
public function processErrorInfo(array $errorInfo) { public function processErrorInfo(array $errorInfo) {
$code = $errorInfo[1]; $code = $errorInfo[1];
if(isset(self::$errorCodeMap[$code])) { if (isset(self::$errorCodeMap[$code])) {
$this->portableCode = self::$errorCodeMap[$code]; $this->portableCode = self::$errorCodeMap[$code];
return true; return true;
} }
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -67,14 +67,14 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common { ...@@ -67,14 +67,14 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
'identifier_quoting' => true, 'identifier_quoting' => true,
'pattern_escaping' => true 'pattern_escaping' => true
); );
$this->properties['string_quoting'] = array('start' => "'", $this->properties['string_quoting'] = array('start' => "'",
'end' => "'", 'end' => "'",
'escape' => '\\', 'escape' => '\\',
'escape_pattern' => '\\'); 'escape_pattern' => '\\');
$this->properties['identifier_quoting'] = array('start' => '`', $this->properties['identifier_quoting'] = array('start' => '`',
'end' => '`', 'end' => '`',
'escape' => '`'); 'escape' => '`');
$this->properties['sql_comments'] = array( $this->properties['sql_comments'] = array(
...@@ -85,7 +85,6 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common { ...@@ -85,7 +85,6 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
$this->properties['varchar_max_length'] = 255; $this->properties['varchar_max_length'] = 255;
parent::__construct($manager, $adapter); parent::__construct($manager, $adapter);
} }
/** /**
...@@ -118,7 +117,7 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common { ...@@ -118,7 +117,7 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
$value = $this->dbh->lastInsertId(); $value = $this->dbh->lastInsertId();
if(is_numeric($value)) { if (is_numeric($value)) {
$query = 'DELETE FROM ' . $sequenceName . ' WHERE ' . $seqcolName . ' < ' . $value; $query = 'DELETE FROM ' . $sequenceName . ' WHERE ' . $seqcolName . ' < ' . $value;
$result = $this->dbh->query($query); $result = $this->dbh->query($query);
} }
...@@ -205,17 +204,17 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common { ...@@ -205,17 +204,17 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
$query = $values = ''; $query = $values = '';
$keys = $colnum = 0; $keys = $colnum = 0;
for(reset($fields); $colnum < $count; next($fields), $colnum++) { for (reset($fields); $colnum < $count; next($fields), $colnum++) {
$name = key($fields); $name = key($fields);
if($colnum > 0) { if ($colnum > 0) {
$query .= ','; $query .= ',';
$values.= ','; $values.= ',';
} }
$query .= $name; $query .= $name;
if(isset($fields[$name]['null']) && $fields[$name]['null']) { if (isset($fields[$name]['null']) && $fields[$name]['null']) {
$value = 'NULL'; $value = 'NULL';
} else { } else {
$type = isset($fields[$name]['type']) ? $fields[$name]['type'] : null; $type = isset($fields[$name]['type']) ? $fields[$name]['type'] : null;
...@@ -224,18 +223,17 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common { ...@@ -224,18 +223,17 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
$values .= $value; $values .= $value;
if(isset($fields[$name]['key']) && $fields[$name]['key']) { if (isset($fields[$name]['key']) && $fields[$name]['key']) {
if($value === 'NULL') if ($value === 'NULL') {
throw new Doctrine_Connection_Mysql_Exception('key value '.$name.' may not be NULL'); throw new Doctrine_Connection_Mysql_Exception('key value '.$name.' may not be NULL');
}
$keys++; $keys++;
} }
} }
if($keys == 0) if ($keys == 0) {
throw new Doctrine_Connection_Mysql_Exception('not specified which fields are keys'); throw new Doctrine_Connection_Mysql_Exception('not specified which fields are keys');
}
$query = 'REPLACE INTO ' . $table . ' (' . $query . ') VALUES (' . $values . ')'; $query = 'REPLACE INTO ' . $table . ' (' . $query . ') VALUES (' . $values . ')';
return $this->dbh->exec($query); return $this->dbh->exec($query);
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Connection_Exception'); ...@@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
*/ */
class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception { class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception {
/** /**
* @var array $errorCodeMap an array that is used for determining portable * @var array $errorCodeMap an array that is used for determining portable
* error code from a native database error code * error code from a native database error code
...@@ -63,7 +63,7 @@ class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception ...@@ -63,7 +63,7 @@ class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception
); );
/** /**
* This method checks if native error code/message can be * This method checks if native error code/message can be
* converted into a portable code and then adds this * converted into a portable code and then adds this
* portable error code to $portableCode field * portable error code to $portableCode field
* *
* @param array $errorInfo error info array * @param array $errorInfo error info array
...@@ -73,7 +73,7 @@ class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception ...@@ -73,7 +73,7 @@ class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception
*/ */
public function processErrorInfo(array $errorInfo) { public function processErrorInfo(array $errorInfo) {
$code = $errorInfo[1]; $code = $errorInfo[1];
if(isset(self::$errorCodeMap[$code])) { if (isset(self::$errorCodeMap[$code])) {
$this->portableCode = self::$errorCodeMap[$code]; $this->portableCode = self::$errorCodeMap[$code];
return true; return true;
} }
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -35,8 +35,7 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection { ...@@ -35,8 +35,7 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
* @var string $driverName the name of this connection driver * @var string $driverName the name of this connection driver
*/ */
protected $driverName = 'Oracle'; protected $driverName = 'Oracle';
public function __construct(Doctrine_Manager $manager, $adapter) { public function __construct(Doctrine_Manager $manager, $adapter) {
$this->supported = array( $this->supported = array(
'sequences' => true, 'sequences' => true,
...@@ -127,4 +126,3 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection { ...@@ -127,4 +126,3 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
return $data[0]; return $data[0];
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Connection_Exception'); ...@@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
*/ */
class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception { class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception {
/** /**
* @var array $errorCodeMap an array that is used for determining portable * @var array $errorCodeMap an array that is used for determining portable
* error code from a native database error code * error code from a native database error code
...@@ -58,7 +58,7 @@ class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception ...@@ -58,7 +58,7 @@ class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception
); );
/** /**
* This method checks if native error code/message can be * This method checks if native error code/message can be
* converted into a portable code and then adds this * converted into a portable code and then adds this
* portable error code to $portableCode field * portable error code to $portableCode field
* *
* @param array $errorInfo error info array * @param array $errorInfo error info array
...@@ -68,7 +68,7 @@ class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception ...@@ -68,7 +68,7 @@ class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception
*/ */
public function processErrorInfo(array $errorInfo) { public function processErrorInfo(array $errorInfo) {
$code = $errorInfo[1]; $code = $errorInfo[1];
if(isset(self::$errorCodeMap[$code])) { if (isset(self::$errorCodeMap[$code])) {
$this->portableCode = self::$errorCodeMap[$code]; $this->portableCode = self::$errorCodeMap[$code];
return true; return true;
} }
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -65,8 +65,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common { ...@@ -65,8 +65,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
'pattern_escaping' => true, 'pattern_escaping' => true,
); );
$this->properties['string_quoting'] = array('start' => "'", $this->properties['string_quoting'] = array('start' => "'",
'end' => "'", 'end' => "'",
'escape' => "'", 'escape' => "'",
'escape_pattern' => '\\'); 'escape_pattern' => '\\');
...@@ -119,23 +119,23 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common { ...@@ -119,23 +119,23 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) { public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) {
if ($limit > 0) { if ($limit > 0) {
$query = rtrim($query); $query = rtrim($query);
if (substr($query, -1) == ';') { if (substr($query, -1) == ';') {
$query = substr($query, 0, -1); $query = substr($query, 0, -1);
} }
if ($isManip) { if ($isManip) {
$manip = preg_replace('/^(DELETE FROM|UPDATE).*$/', '\\1', $query); $manip = preg_replace('/^(DELETE FROM|UPDATE).*$/', '\\1', $query);
$from = $match[2]; $from = $match[2];
$where = $match[3]; $where = $match[3];
$query = $manip . ' ' . $from . ' WHERE ctid=(SELECT ctid FROM ' $query = $manip . ' ' . $from . ' WHERE ctid=(SELECT ctid FROM '
. $from . ' ' . $where . ' LIMIT ' . $limit . ')'; . $from . ' ' . $where . ' LIMIT ' . $limit . ')';
} else { } else {
if($limit !== false) { if ($limit !== false) {
$query .= ' LIMIT ' . $limit; $query .= ' LIMIT ' . $limit;
} }
if($offset !== false) { if ($offset !== false) {
$query .= ' OFFSET ' . $offset; $query .= ' OFFSET ' . $offset;
} }
} }
...@@ -153,12 +153,12 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common { ...@@ -153,12 +153,12 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
$serverInfo = $this->fetchOne($query); $serverInfo = $this->fetchOne($query);
if( ! $native) { if ( ! $native) {
$tmp = explode('.', $server_info, 3); $tmp = explode('.', $server_info, 3);
if(empty($tmp[2]) && isset($tmp[1])
&& preg_match('/(\d+)(.*)/', $tmp[1], $tmp2)) {
if (empty($tmp[2]) && isset($tmp[1])
&& preg_match('/(\d+)(.*)/', $tmp[1], $tmp2)
) {
$serverInfo = array( $serverInfo = array(
'major' => $tmp[0], 'major' => $tmp[0],
'minor' => $tmp2[1], 'minor' => $tmp2[1],
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -32,9 +32,9 @@ Doctrine::autoload('Doctrine_Connection_Exception'); ...@@ -32,9 +32,9 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
*/ */
class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception { class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception {
/** /**
* @var array $errorRegexps an array that is used for determining portable * @var array $errorRegexps an array that is used for determining portable
* error code from a native database error message * error code from a native database error message
*/ */
protected static $errorRegexps = array( protected static $errorRegexps = array(
...@@ -81,7 +81,7 @@ class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception ...@@ -81,7 +81,7 @@ class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception
); );
/** /**
* This method checks if native error code/message can be * This method checks if native error code/message can be
* converted into a portable code and then adds this * converted into a portable code and then adds this
* portable error code to $portableCode field * portable error code to $portableCode field
* *
* the portable error code is added at the end of array * the portable error code is added at the end of array
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -31,7 +31,7 @@ Doctrine::autoload("Doctrine_Connection_Common"); ...@@ -31,7 +31,7 @@ Doctrine::autoload("Doctrine_Connection_Common");
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
*/ */
class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common { class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
/** /**
* @var string $driverName the name of this connection driver * @var string $driverName the name of this connection driver
*/ */
...@@ -43,7 +43,7 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common { ...@@ -43,7 +43,7 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
* @param PDO $pdo database handle * @param PDO $pdo database handle
*/ */
public function __construct(Doctrine_Manager $manager, $adapter) { public function __construct(Doctrine_Manager $manager, $adapter) {
$this->supported = array( $this->supported = array(
'sequences' => 'emulated', 'sequences' => 'emulated',
'indexes' => true, 'indexes' => true,
...@@ -96,4 +96,3 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common { ...@@ -96,4 +96,3 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
return $data[0]; return $data[0];
} }
} }
<?php <?php
/* /*
* $Id$ * $Id$
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
...@@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Connection_Exception'); ...@@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Connection_Exception');
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
*/ */
class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception { class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception {
/** /**
* @var array $errorRegexps an array that is used for determining portable * @var array $errorRegexps an array that is used for determining portable
* error code from a native database error message * error code from a native database error message
...@@ -52,7 +52,7 @@ class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception ...@@ -52,7 +52,7 @@ class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
); );
/** /**
* This method checks if native error code/message can be * This method checks if native error code/message can be
* converted into a portable code and then adds this * converted into a portable code and then adds this
* portable error code to $portableCode field * portable error code to $portableCode field
* *
* @param array $errorInfo error info array * @param array $errorInfo error info array
...@@ -63,8 +63,8 @@ class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception ...@@ -63,8 +63,8 @@ class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
* (the process is successfull if portable error code was found) * (the process is successfull if portable error code was found)
*/ */
public function processErrorInfo(array $errorInfo) { public function processErrorInfo(array $errorInfo) {
foreach(self::$errorRegexps as $regexp => $code) { foreach (self::$errorRegexps as $regexp => $code) {
if(preg_match($regexp, $errorInfo[2])) { if (preg_match($regexp, $errorInfo[2])) {
$this->portableCode = $code; $this->portableCode = $code;
return true; return true;
......
This diff is collapsed.
...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_Exception'); ...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_Exception');
/** /**
* Doctrine_DataDict_Exception * Doctrine_DataDict_Exception
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_DataDict_Exception extends Doctrine_Exception { } class Doctrine_DataDict_Exception extends Doctrine_Exception { }
...@@ -54,39 +54,39 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict { ...@@ -54,39 +54,39 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
* declare the specified field. * declare the specified field.
*/ */
public function getNativeDeclaration($field) { public function getNativeDeclaration($field) {
switch($field['type']) { switch ($field['type']) {
case 'varchar': case 'varchar':
case 'string': case 'string':
case 'array': case 'array':
case 'object': case 'object':
case 'char': case 'char':
case 'text': case 'text':
$length = !empty($field['length']) $length = !empty($field['length'])
? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length']; ? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length'];
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? 'CHAR('.$length.')' : 'VARCHAR('.$length.')'; return $fixed ? 'CHAR('.$length.')' : 'VARCHAR('.$length.')';
case 'clob': case 'clob':
return 'BLOB SUB_TYPE 1'; return 'BLOB SUB_TYPE 1';
case 'blob': case 'blob':
return 'BLOB SUB_TYPE 0'; return 'BLOB SUB_TYPE 0';
case 'integer': case 'integer':
case 'enum': case 'enum':
return 'INT'; return 'INT';
case 'boolean': case 'boolean':
return 'SMALLINT'; return 'SMALLINT';
case 'date': case 'date':
return 'DATE'; return 'DATE';
case 'time': case 'time':
return 'TIME'; return 'TIME';
case 'timestamp': case 'timestamp':
return 'TIMESTAMP'; return 'TIMESTAMP';
case 'float': case 'float':
return 'DOUBLE PRECISION'; return 'DOUBLE PRECISION';
case 'decimal': case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18; $length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; return 'DECIMAL('.$length.','.$db->options['decimal_places'].')';
} }
return ''; return '';
} }
...@@ -99,7 +99,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict { ...@@ -99,7 +99,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
public function getPortableDeclaration($field) { public function getPortableDeclaration($field) {
$length = $field['length']; $length = $field['length'];
if((int) $length <= 0) if ((int) $length <= 0)
$length = null; $length = null;
$type = array(); $type = array();
...@@ -108,67 +108,67 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict { ...@@ -108,67 +108,67 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
$field['field_sub_type'] = !empty($field['field_sub_type']) $field['field_sub_type'] = !empty($field['field_sub_type'])
? strtolower($field['field_sub_type']) : null; ? strtolower($field['field_sub_type']) : null;
switch ($db_type) { switch ($db_type) {
case 'smallint': case 'smallint':
case 'integer': case 'integer':
case 'int64': case 'int64':
//these may be 'numeric' or 'decimal' //these may be 'numeric' or 'decimal'
if (isset($field['field_sub_type'])) { if (isset($field['field_sub_type'])) {
$field['type'] = $field['field_sub_type']; $field['type'] = $field['field_sub_type'];
return $this->mapNativeDatatype($field); return $this->mapNativeDatatype($field);
}
case 'bigint':
case 'quad':
$type[] = 'integer';
if ($length == '1') {
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
} }
case 'bigint': }
case 'quad': break;
$type[] = 'integer'; case 'varchar':
if ($length == '1') { $fixed = false;
$type[] = 'boolean'; case 'char':
if (preg_match('/^(is|has)/', $field['name'])) { case 'cstring':
$type = array_reverse($type); $type[] = 'text';
} if ($length == '1') {
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
} }
break; }
case 'varchar': if ($fixed !== false) {
$fixed = false; $fixed = true;
case 'char': }
case 'cstring': break;
$type[] = 'text'; case 'date':
if ($length == '1') { $type[] = 'date';
$type[] = 'boolean'; $length = null;
if (preg_match('/^(is|has)/', $field['name'])) { break;
$type = array_reverse($type); case 'timestamp':
} $type[] = 'timestamp';
} $length = null;
if ($fixed !== false) { break;
$fixed = true; case 'time':
} $type[] = 'time';
break; $length = null;
case 'date': break;
$type[] = 'date'; case 'float':
$length = null; case 'double':
break; case 'double precision':
case 'timestamp': case 'd_float':
$type[] = 'timestamp'; $type[] = 'float';
$length = null; break;
break; case 'decimal':
case 'time': case 'numeric':
$type[] = 'time'; $type[] = 'decimal';
$length = null; break;
break; case 'blob':
case 'float': $type[] = ($field['field_sub_type'] == 'text') ? 'clob' : 'blob';
case 'double': $length = null;
case 'double precision': break;
case 'd_float': default:
$type[] = 'float'; throw new Doctrine_DataDict_Firebird_Exception('unknown database attribute type: '.$db_type);
break;
case 'decimal':
case 'numeric':
$type[] = 'decimal';
break;
case 'blob':
$type[] = ($field['field_sub_type'] == 'text') ? 'clob' : 'blob';
$length = null;
break;
default:
throw new Doctrine_DataDict_Firebird_Exception('unknown database attribute type: '.$db_type);
} }
return array($type, $length, $unsigned, $fixed); return array($type, $length, $unsigned, $fixed);
......
...@@ -55,52 +55,51 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict { ...@@ -55,52 +55,51 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict {
*/ */
public function getNativeDeclaration($field) { public function getNativeDeclaration($field) {
switch ($field['type']) { switch ($field['type']) {
case 'char': case 'char':
case 'varchar': case 'varchar':
case 'array': case 'array':
case 'object': case 'object':
case 'string': case 'string':
if (empty($field['length']) && array_key_exists('default', $field)) { if (empty($field['length']) && array_key_exists('default', $field)) {
$field['length'] = $this->conn->varchar_max_length; $field['length'] = $this->conn->varchar_max_length;
} }
$length = (! empty($field['length'])) ? $field['length'] : false; $length = (! empty($field['length'])) ? $field['length'] : false;
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR(255)') return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR(255)')
: ($length ? 'VARCHAR('.$length.')' : 'NVARCHAR'); : ($length ? 'VARCHAR('.$length.')' : 'NVARCHAR');
case 'clob': case 'clob':
return 'TEXT'; return 'TEXT';
case 'blob': case 'blob':
return 'BLOB'; return 'BLOB';
case 'integer': case 'integer':
if (!empty($field['length'])) { if (!empty($field['length'])) {
$length = $field['length']; $length = $field['length'];
if ($length <= 1) { if ($length <= 1) {
return 'SMALLINT'; return 'SMALLINT';
} elseif ($length == 2) { } elseif ($length == 2) {
return 'SMALLINT'; return 'SMALLINT';
} elseif ($length == 3 || $length == 4) { } elseif ($length == 3 || $length == 4) {
return 'INTEGER'; return 'INTEGER';
} elseif ($length > 4) { } elseif ($length > 4) {
return 'DECIMAL(20)'; return 'DECIMAL(20)';
}
} }
return 'INT'; }
case 'boolean': return 'INT';
return 'SMALLINT'; case 'boolean':
case 'date': return 'SMALLINT';
return 'DATE'; case 'date':
case 'time': return 'DATE';
return 'DATETIME YEAR TO SECOND'; case 'time':
case 'timestamp': return 'DATETIME YEAR TO SECOND';
return 'DATETIME'; case 'timestamp':
case 'float': return 'DATETIME';
return 'FLOAT'; case 'float':
case 'decimal': return 'FLOAT';
return 'DECIMAL'; case 'decimal':
return 'DECIMAL';
} }
return ''; return '';
} }
} }
...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_DataDict_Informix_Exception'); ...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_DataDict_Informix_Exception');
/** /**
* Doctrine_DataDict_Sqlite_Exception * Doctrine_DataDict_Sqlite_Exception
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_DataDict_Informix_Exception extends Doctrine_DataDict_Exception { } class Doctrine_DataDict_Informix_Exception extends Doctrine_DataDict_Exception { }
...@@ -57,51 +57,51 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict { ...@@ -57,51 +57,51 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict {
*/ */
public function getNativeDeclaration($field) { public function getNativeDeclaration($field) {
switch ($field['type']) { switch ($field['type']) {
case 'array': case 'array':
case 'object': case 'object':
case 'text': case 'text':
case 'char': case 'char':
case 'varchar': case 'varchar':
case 'string': case 'string':
$length = !empty($field['length']) $length = !empty($field['length'])
? $field['length'] : false; ? $field['length'] : false;
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')')
: ($length ? 'VARCHAR('.$length.')' : 'TEXT'); : ($length ? 'VARCHAR('.$length.')' : 'TEXT');
case 'clob': case 'clob':
if (!empty($field['length'])) { if (!empty($field['length'])) {
$length = $field['length']; $length = $field['length'];
if ($length <= 8000) { if ($length <= 8000) {
return 'VARCHAR('.$length.')'; return 'VARCHAR('.$length.')';
}
}
return 'TEXT';
case 'blob':
if (!empty($field['length'])) {
$length = $field['length'];
if ($length <= 8000) {
return "VARBINARY($length)";
}
} }
return 'IMAGE'; }
case 'integer': return 'TEXT';
case 'enum': case 'blob':
return 'INT'; if (!empty($field['length'])) {
case 'boolean': $length = $field['length'];
return 'BIT'; if ($length <= 8000) {
case 'date': return "VARBINARY($length)";
return 'CHAR(' . strlen('YYYY-MM-DD') . ')'; }
case 'time': }
return 'CHAR(' . strlen('HH:MM:SS') . ')'; return 'IMAGE';
case 'timestamp': case 'integer':
return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')'; case 'enum':
case 'float': return 'INT';
return 'FLOAT'; case 'boolean':
case 'decimal': return 'BIT';
$length = !empty($field['length']) ? $field['length'] : 18; case 'date':
return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; return 'CHAR(' . strlen('YYYY-MM-DD') . ')';
case 'time':
return 'CHAR(' . strlen('HH:MM:SS') . ')';
case 'timestamp':
return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')';
case 'float':
return 'FLOAT';
case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL('.$length.','.$db->options['decimal_places'].')';
} }
return ''; return '';
} }
...@@ -121,48 +121,48 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict { ...@@ -121,48 +121,48 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict {
// todo: unsigned handling seems to be missing // todo: unsigned handling seems to be missing
$unsigned = $fixed = null; $unsigned = $fixed = null;
switch ($db_type) { switch ($db_type) {
case 'bit': case 'bit':
$type[0] = 'boolean'; $type[0] = 'boolean';
break; break;
case 'int': case 'int':
$type[0] = 'integer'; $type[0] = 'integer';
break; break;
case 'datetime': case 'datetime':
$type[0] = 'timestamp'; $type[0] = 'timestamp';
break; break;
case 'float': case 'float':
case 'real': case 'real':
case 'numeric': case 'numeric':
$type[0] = 'float'; $type[0] = 'float';
break; break;
case 'decimal': case 'decimal':
case 'money': case 'money':
$type[0] = 'decimal'; $type[0] = 'decimal';
break; break;
case 'text': case 'text':
case 'varchar': case 'varchar':
$fixed = false; $fixed = false;
case 'char': case 'char':
$type[0] = 'text'; $type[0] = 'text';
if ($length == '1') { if ($length == '1') {
$type[] = 'boolean'; $type[] = 'boolean';
if (preg_match('/^[is|has]/', $field['name'])) { if (preg_match('/^[is|has]/', $field['name'])) {
$type = array_reverse($type); $type = array_reverse($type);
}
} elseif (strstr($db_type, 'text')) {
$type[] = 'clob';
}
if ($fixed !== false) {
$fixed = true;
} }
break; } elseif (strstr($db_type, 'text')) {
case 'image': $type[] = 'clob';
case 'varbinary': }
$type[] = 'blob'; if ($fixed !== false) {
$length = null; $fixed = true;
break; }
default: break;
throw new Doctrine_DataDict_Mssql_Exception('unknown database attribute type: '.$db_type); case 'image':
case 'varbinary':
$type[] = 'blob';
$length = null;
break;
default:
throw new Doctrine_DataDict_Mssql_Exception('unknown database attribute type: '.$db_type);
} }
return array($type, $length, $unsigned, $fixed); return array($type, $length, $unsigned, $fixed);
......
This diff is collapsed.
...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_DataDict_Exception'); ...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
/** /**
* Doctrine_DataDict_Mysql_Exception * Doctrine_DataDict_Mysql_Exception
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_DataDict_Mysql_Exception extends Doctrine_DataDict_Exception { } class Doctrine_DataDict_Mysql_Exception extends Doctrine_DataDict_Exception { }
...@@ -52,38 +52,38 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict { ...@@ -52,38 +52,38 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict {
*/ */
public function getNativeDeclaration(array $field) { public function getNativeDeclaration(array $field) {
switch ($field['type']) { switch ($field['type']) {
case 'string': case 'string':
case 'array': case 'array':
case 'object': case 'object':
case 'gzip': case 'gzip':
case 'char': case 'char':
case 'varchar': case 'varchar':
$length = !empty($field['length']) $length = !empty($field['length'])
? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length']; ? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length'];
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')'; return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')';
case 'clob': case 'clob':
return 'CLOB'; return 'CLOB';
case 'blob': case 'blob':
return 'BLOB'; return 'BLOB';
case 'integer': case 'integer':
case 'enum': case 'enum':
if (!empty($field['length'])) { if (!empty($field['length'])) {
return 'NUMBER('.$field['length'].')'; return 'NUMBER('.$field['length'].')';
} }
return 'INT'; return 'INT';
case 'boolean': case 'boolean':
return 'NUMBER(1)'; return 'NUMBER(1)';
case 'date': case 'date':
case 'time': case 'time':
case 'timestamp': case 'timestamp':
return 'DATE'; return 'DATE';
case 'float': case 'float':
return 'NUMBER'; return 'NUMBER';
case 'decimal': case 'decimal':
return 'NUMBER(*,'.$db->options['decimal_places'].')'; return 'NUMBER(*,'.$db->options['decimal_places'].')';
} }
} }
/** /**
...@@ -101,72 +101,72 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict { ...@@ -101,72 +101,72 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict {
$length = $field['length']; $length = $field['length'];
} }
switch ($db_type) { switch ($db_type) {
case 'integer': case 'integer':
case 'pls_integer': case 'pls_integer':
case 'binary_integer': case 'binary_integer':
$type[] = 'integer'; $type[] = 'integer';
if ($length == '1') { if ($length == '1') {
$type[] = 'boolean'; $type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) { if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type); $type = array_reverse($type);
} }
}
break;
case 'varchar':
case 'varchar2':
case 'nvarchar2':
$fixed = false;
case 'char':
case 'nchar':
$type[] = 'text';
if ($length == '1') {
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
} }
break; }
case 'varchar': if ($fixed !== false) {
case 'varchar2': $fixed = true;
case 'nvarchar2': }
$fixed = false; break;
case 'char': case 'date':
case 'nchar': case 'timestamp':
$type[] = 'text'; $type[] = 'timestamp';
$length = null;
break;
case 'float':
$type[] = 'float';
break;
case 'number':
if (!empty($field['scale'])) {
$type[] = 'decimal';
} else {
$type[] = 'integer';
if ($length == '1') { if ($length == '1') {
$type[] = 'boolean'; $type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) { if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type); $type = array_reverse($type);
} }
} }
if ($fixed !== false) { }
$fixed = true; break;
} case 'long':
break; $type[] = 'text';
case 'date': case 'clob':
case 'timestamp': case 'nclob':
$type[] = 'timestamp'; $type[] = 'clob';
$length = null;
break;
case 'float':
$type[] = 'float';
break;
case 'number':
if (!empty($field['scale'])) {
$type[] = 'decimal';
} else {
$type[] = 'integer';
if ($length == '1') {
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
}
}
}
break;
case 'long':
$type[] = 'text';
case 'clob':
case 'nclob':
$type[] = 'clob';
break;
case 'blob':
case 'raw':
case 'long raw':
case 'bfile':
$type[] = 'blob';
$length = null;
break; break;
case 'rowid': case 'blob':
case 'urowid': case 'raw':
default: case 'long raw':
throw new Doctrine_DataDict_Oracle_Exception('unknown database attribute type: '.$db_type); case 'bfile':
$type[] = 'blob';
$length = null;
break;
case 'rowid':
case 'urowid':
default:
throw new Doctrine_DataDict_Oracle_Exception('unknown database attribute type: '.$db_type);
} }
return array($type, $length, $unsigned, $fixed); return array($type, $length, $unsigned, $fixed);
......
...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_DataDict_Exception'); ...@@ -22,12 +22,12 @@ Doctrine::autoload('Doctrine_DataDict_Exception');
/** /**
* Doctrine_DataDict_Oracle_Exception * Doctrine_DataDict_Oracle_Exception
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping * @category Object Relational Mapping
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_DataDict_Oracle_Exception extends Doctrine_DataDict_Exception { } class Doctrine_DataDict_Oracle_Exception extends Doctrine_DataDict_Exception { }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment