Commit 716bb65b authored by lsmith's avatar lsmith

- first round of PEAR CS fixes

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