Mise a jour Doctrine 1.1.2 a la version 1.1.3

This commit is contained in:
Michael RICOIS 2009-08-03 10:38:43 +00:00
parent c48b5bdf29
commit 666b9719aa
25 changed files with 285 additions and 210 deletions

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Doctrine.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
* $Id: Doctrine.php 6160 2009-07-24 19:20:08Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -29,14 +29,14 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @version $Revision: 6160 $
*/
final class Doctrine
{
/**
* VERSION
*/
const VERSION = '1.1.2';
const VERSION = '1.1.3';
/**
* ERROR CONSTANTS
@ -543,7 +543,7 @@ final class Doctrine
$declaredAfter = get_declared_classes();
// Using array_slice because array_diff is broken is some PHP versions
$foundClasses = array_slice($declaredAfter, count($declaredBefore) - 1);
$foundClasses = array_slice($declaredAfter, count($declaredBefore));
if ($foundClasses) {
foreach ($foundClasses as $className) {
if (self::isValidModelClass($className)) {
@ -563,7 +563,7 @@ final class Doctrine
}
}
}
asort($loadedModels);
return $loadedModels;
}

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Db.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
* $Id: Db.php 6148 2009-07-21 20:45:03Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -27,7 +27,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @version $Revision: 6148 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Cache_Db extends Doctrine_Cache_Driver implements Countable
@ -97,6 +97,10 @@ class Doctrine_Cache_Db extends Doctrine_Cache_Driver implements Countable
return null;
}
if (bin2hex($hex) == $hex) {
return $hex;
}
$bin = '';
for ($a = 0; $a < strlen($hex); $a += 2) {
$bin .= chr(hexdec($hex{$a} . $hex{($a + 1)}));
@ -143,7 +147,7 @@ class Doctrine_Cache_Db extends Doctrine_Cache_Driver implements Countable
. ' WHERE id = ?';
if ($lifeTime) {
$expire = date('Y-m-d H:i:s',time() + $lifeTime);
$expire = date('Y-m-d H:i:s', time() + $lifeTime);
} else {
$expire = NULL;
}

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Connection.php 5876 2009-06-10 18:43:12Z piccoloprincipe $
* $Id: Connection.php 6152 2009-07-21 21:59:32Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -49,7 +49,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5876 $
* @version $Revision: 6152 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (MDB2 library)
*/
@ -1527,7 +1527,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$username = $this->getOption('username');
$password = $this->getOption('password');
return $this->getManager()->openConnection(new PDO($pdoDsn, $username, $password), 'doctrine_tmp_connection', false);
$conn = $this->getManager()->openConnection(array($pdoDsn, $username, $password), 'doctrine_tmp_connection', false);
$conn->setOption('username', $username);
$conn->setOption('password', $password);
return $conn;
}
/**
@ -1650,8 +1654,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$name = $generated;
}
$count = 1;
while (in_array($name, $this->_usedNames[$type])) {
$e = explode('_', $name);
$end = end($e);
@ -1659,15 +1661,10 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if (is_numeric($end)) {
unset($e[count($e) - 1]);
$fkName = implode('_', $e);
$name = $fkName . '_' . ++$end;
} else {
$name .= '_1';
}
$name = $name . '_' . $count;
if (strlen($name) > $maxLength) {
$name = substr($name, 0, $maxLength - strlen($count)) . '_' . $count;
}
$count++;
}
$this->_usedNames[$type][$key] = $name;

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Oracle.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
* $Id: Oracle.php 5893 2009-06-16 15:25:42Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -27,7 +27,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @version $Revision: 5893 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Connection_Oracle extends Doctrine_Connection_Common
@ -132,4 +132,9 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection_Common
$column = $columnNames[0];
return $this->_createLimitSubquery($query, $limit, $offset, $column);
}
public function getTmpConnection($info)
{
return $this;
}
}

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: UnitOfWork.php 5882 2009-06-15 03:37:44Z guilhermeblanco $
* $Id: UnitOfWork.php 6124 2009-07-20 17:47:01Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -33,7 +33,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5882 $
* @version $Revision: 6124 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
@ -741,8 +741,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
continue;
}
unset($flushList[$index]);
array_splice($flushList, $index3, 0, $assocClassName);
unset($flushList[$index3]);
array_splice($flushList, $index - 1, 0, $assocClassName);
$index = $relatedCompIndex;
} else {
$flushList[] = $assocClassName;

View File

@ -83,8 +83,13 @@ class Doctrine_Data_Import extends Doctrine_Data
} else if(is_dir($dir)) {
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir),
RecursiveIteratorIterator::LEAVES_ONLY);
$filesOrdered = array();
foreach ($it as $file) {
$filesOrdered[] = $file;
}
// force correct order
natcasesort($filesOrdered);
foreach ($filesOrdered as $file) {
$e = explode('.', $file->getFileName());
if (in_array(end($e), $this->getFormats())) {
$array = $mergeFunction($array, Doctrine_Parser::load($file->getPathName(), $this->getFormat()));

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Mssql.php 5848 2009-06-09 08:15:56Z jwage $
* $Id: Mssql.php 6051 2009-07-10 17:53:44Z dcousineau $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -27,7 +27,7 @@
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @author Frank M. Kromann <frank@kromann.info> (PEAR MDB2 Mssql driver)
* @author David Coallier <davidc@php.net> (PEAR MDB2 Mssql driver)
* @version $Revision: 5848 $
* @version $Revision: 6051 $
* @link www.phpdoctrine.org
* @since 1.0
*/
@ -96,7 +96,7 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict
return 'IMAGE';
case 'integer':
case 'int':
return 'INT';
return (isset($field['unsigned']) && $field['unsigned']) ? 'BIGINT' : 'INT';
case 'boolean':
return 'BIT';
case 'date':
@ -242,7 +242,9 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict
$notnull = (isset($field['notnull']) && $field['notnull']) ? ' NOT NULL' : '';
$unsigned = (isset($field['unsigned']) && $field['unsigned']) ? ' UNSIGNED' : '';
//$unsigned = (isset($field['unsigned']) && $field['unsigned']) ? ' UNSIGNED' : '';
// MSSQL does not support the UNSIGNED keyword
$unsigned = '';
$comment = (isset($field['comment']) && $field['comment'])
? " COMMENT '" . $field['comment'] . "'" : '';

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Oracle.php 5876 2009-06-10 18:43:12Z piccoloprincipe $
* $Id: Oracle.php 5893 2009-06-16 15:25:42Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -29,7 +29,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5876 $
* @version $Revision: 5893 $
*/
class Doctrine_Export_Oracle extends Doctrine_Export
{
@ -42,13 +42,11 @@ class Doctrine_Export_Oracle extends Doctrine_Export
*/
public function createDatabase($name)
{
if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE))
throw new Doctrine_Export_Exception('database creation is only supported if the "emulate_database" attribute is enabled');
$username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name);
if ($this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) {
$username = $name;
$password = $this->conn->dsn['password'] ? $this->conn->dsn['password'] : $name;
$tablespace = $this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT)
$tablespace = $this->conn->options['default_tablespace']
? ' DEFAULT TABLESPACE '.$this->conn->options['default_tablespace'] : '';
$query = 'CREATE USER ' . $username . ' IDENTIFIED BY ' . $password . $tablespace;
@ -58,9 +56,10 @@ class Doctrine_Export_Oracle extends Doctrine_Export
$query = 'GRANT CREATE SESSION, CREATE TABLE, UNLIMITED TABLESPACE, CREATE SEQUENCE, CREATE TRIGGER TO ' . $username;
$result = $this->conn->exec($query);
} catch (Exception $e) {
$query = 'DROP USER '.$username.' CASCADE';
$result2 = $this->conn->exec($query);
$this->dropDatabase($username);
}
}
return true;
}
@ -74,13 +73,28 @@ class Doctrine_Export_Oracle extends Doctrine_Export
*/
public function dropDatabase($name)
{
if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE))
throw new Doctrine_Export_Exception('database dropping is only supported if the
"emulate_database" option is enabled');
$sql[] = "BEGIN
FOR I IN (select table_name from user_tables)
LOOP
EXECUTE IMMEDIATE 'DROP TABLE '||I.table_name||' CASCADE CONSTRAINTS';
END LOOP;
END;";
$username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name);
$sql[] = "BEGIN
FOR I IN (SELECT SEQUENCE_NAME, SEQUENCE_OWNER FROM ALL_SEQUENCES WHERE SEQUENCE_OWNER <> 'SYS')
LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE '||I.SEQUENCE_OWNER||'.'||I.SEQUENCE_NAME;
END LOOP;
END;";
return $this->conn->exec('DROP USER ' . $username . ' CASCADE');
foreach ($sql as $query) {
$this->conn->exec($query);
}
if ($this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) {
$username = $name;
$this->conn->exec('DROP USER ' . $username . ' CASCADE');
}
}
/**
@ -135,7 +149,6 @@ DECLARE
last_Sequence NUMBER;
last_InsertID NUMBER;
BEGIN
SELECT ' . $this->conn->quoteIdentifier($sequenceName) . '.NEXTVAL INTO :NEW.' . $name . ' FROM DUAL;
IF (:NEW.' . $name . ' IS NULL OR :NEW.'.$name.' = 0) THEN
SELECT ' . $this->conn->quoteIdentifier($sequenceName) . '.NEXTVAL INTO :NEW.' . $name . ' FROM DUAL;
ELSE

View File

@ -155,17 +155,32 @@ class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable
return $component;
}
$matchedComponents = array($component);
foreach ($subclasses as $subclass) {
$table = Doctrine::getTable($subclass);
$inheritanceMap = $table->getOption('inheritanceMap');
if (count($inheritanceMap) > 1) {
$needMatches = count($inheritanceMap);
foreach ($inheritanceMap as $key => $value) {
$key = $this->_tables[$component]->getFieldName($key);
if ( isset($data[$key]) && $data[$key] == $value) {
--$needMatches;
}
}
if ($needMatches == 0) {
$matchedComponents[] = $table->getComponentName();
}
} else {
list($key, $value) = each($inheritanceMap);
$key = $this->_tables[$component]->getFieldName($key);
if ( ! isset($data[$key]) || $data[$key] != $value) {
continue;
} else {
return $table->getComponentName();
$matchedComponents[] = $table->getComponentName();
}
}
return $component;
}
return $matchedComponents[count($matchedComponents)-1];
}
}

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Import.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
* $Id: Import.php 5976 2009-07-01 04:04:33Z guilhermeblanco $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -30,7 +30,7 @@
* @link www.phpdoctrine.org
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @since 1.0
* @version $Revision: 5798 $
* @version $Revision: 5976 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Jukka Hassinen <Jukka.Hassinen@BrainAlliance.com>
*/
@ -364,6 +364,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
public function importSchema($directory, array $databases = array(), array $options = array())
{
$connections = Doctrine_Manager::getInstance()->getConnections();
$classes = array();
foreach ($connections as $name => $connection) {
// Limit the databases to the ones specified by $databases.
@ -377,7 +378,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
$builder->setOptions($options);
$definitions = array();
$classes = array();
foreach ($connection->import->listTables() as $table) {
$definition = array();
$definition['tableName'] = $table;

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Oracle.php 5850 2009-06-09 08:52:35Z jwage $
* $Id: Oracle.php 6151 2009-07-21 21:50:23Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -24,7 +24,7 @@
* @subpackage Import
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @version $Revision: 5850 $
* @version $Revision: 6151 $
* @link www.phpdoctrine.org
* @since 1.0
*/
@ -40,15 +40,8 @@ class Doctrine_Import_Oracle extends Doctrine_Import
if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) {
throw new Doctrine_Import_Exception('database listing is only supported if the "emulate_database" option is enabled');
}
/**
if ($this->conn->options['database_name_prefix']) {
$query = 'SELECT SUBSTR(username, ';
$query.= (strlen($this->conn->getAttribute(['database_name_prefix'])+1);
$query.= ") FROM sys.dba_users WHERE username LIKE '";
$query.= $this->conn->options['database_name_prefix']."%'";
} else {
*/
$query = 'SELECT username FROM sys.dba_users';
$query = 'SELECT username FROM sys.user_users';
$result2 = $this->conn->standaloneQuery($query);
$result = $result2->fetchColumn();
@ -76,7 +69,8 @@ class Doctrine_Import_Oracle extends Doctrine_Import
*/
public function listTriggers($database = null)
{
$query = "SELECT trigger_name FROM sys.user_triggers";
return $this->conn->fetchColumn($query);
}
/**
@ -182,16 +176,17 @@ QEND;
public function listTableRelations($table)
{
$relations = array();
$sql = 'SELECT ac.table_name AS referenced_table_name, lcc.column_name AS local_column_name, rcc.column_name AS referenced_column_name '
. 'FROM all_constraints ac '
. 'JOIN all_cons_columns lcc ON ac.r_constraint_name = lcc.constraint_name '
. 'JOIN all_cons_columns rcc ON ac.constraint_name = rcc.constraint_name '
. "WHERE ac.constraint_type = 'R'"
. "AND ac.r_constraint_name IN (SELECT constraint_name FROM all_constraints WHERE constraint_type IN ('P', 'U') AND table_name = :tableName)";
$sql = 'SELECT '
. 'rcc.table_name AS referenced_table_name, '
. 'lcc.column_name AS local_column_name, '
. 'rcc.column_name AS referenced_column_name '
. 'FROM user_constraints ac '
. 'JOIN user_cons_columns rcc ON ac.r_constraint_name = rcc.constraint_name '
. 'JOIN user_cons_columns lcc ON ac.constraint_name = lcc.constraint_name '
. "WHERE ac.constraint_type = 'R' AND ac.table_name = :tableName";
$results = $this->conn->fetchAssoc($sql, array(':tableName' => $table));
foreach ($results as $result)
{
foreach ($results as $result) {
$result = array_change_key_case($result, CASE_LOWER);
$relations[] = array('table' => $result['referenced_table_name'],
'local' => $result['local_column_name'],
@ -199,6 +194,7 @@ QEND;
}
return $relations;
}
/**
* lists tables
*
@ -207,7 +203,7 @@ QEND;
*/
public function listTables($database = null)
{
$query = 'SELECT table_name FROM sys.user_tables';
$query = "SELECT * FROM user_objects WHERE object_type = 'TABLE'";
return $this->conn->fetchColumn($query);
}
@ -240,17 +236,7 @@ QEND;
*/
public function listUsers()
{
/**
if ($this->conn->options['emulate_database'] && $this->conn->options['database_name_prefix']) {
$query = 'SELECT SUBSTR(username, ';
$query.= (strlen($this->conn->options['database_name_prefix'])+1);
$query.= ") FROM sys.dba_users WHERE username NOT LIKE '";
$query.= $this->conn->options['database_name_prefix']."%'";
} else {
*/
$query = 'SELECT username FROM sys.dba_users';
//}
$query = 'SELECT username FROM sys.all_users';
return $this->conn->fetchColumn($query);
}

View File

@ -492,7 +492,11 @@ class Doctrine_Import_Schema
while (count($multiInheritanceDef['inheritance']) > 0 && array_key_exists('extends', $multiInheritanceDef['inheritance']) && $multiInheritanceDef['inheritance']['type'] == 'column_aggregation') {
$superClass = $multiInheritanceDef['inheritance']['extends'];
// keep original keyField with it's keyValue
if ( ! isset($inheritanceFields[$multiInheritanceDef['inheritance']['keyField']])) {
$inheritanceFields[$multiInheritanceDef['inheritance']['keyField']] = $multiInheritanceDef['inheritance']['keyValue'];
}
$multiInheritanceDef = $array[$superClass];
}

View File

@ -208,7 +208,9 @@ class Doctrine_Inflector
// Euro Sign
chr(226).chr(130).chr(172) => 'E',
// GBP (Pound) Sign
chr(194).chr(163) => '');
chr(194).chr(163) => '',
'Ä' => 'Ae', 'ä' => 'ae', 'Ü' => 'Ue', 'ü' => 'ue',
'Ö' => 'Oe', 'ö' => 'oe', 'ß' => 'ss');
$string = strtr($string, $chars);
} else {

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Manager.php 5876 2009-06-10 18:43:12Z piccoloprincipe $
* $Id: Manager.php 5893 2009-06-16 15:25:42Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -29,7 +29,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5876 $
* @version $Revision: 5893 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Manager extends Doctrine_Configurable implements Countable, IteratorAggregate
@ -235,7 +235,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
// Decode adapter information
if (is_array($adapter)) {
foreach ($adapter as $key => $value) {
$adapter[$key] = $value?urldecode($value):null;
$adapter[$key] = $value ? urldecode($value):null;
}
}
@ -313,7 +313,14 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$e2 = explode('=', $string);
if (isset($e2[0]) && isset($e2[1])) {
if (count($e2) > 2)
{
$key = $e2[0];
unset($e2[0]);
$value = implode('=', $e2);
} else {
list($key, $value) = $e2;
}
$parts[$key] = $value;
}
}

View File

@ -244,6 +244,9 @@ END;
}
foreach ($addedIndexes as $name => $index) {
if (isset($changes['created_tables'][$tableName]['options']['indexes'][$name])) {
continue;
}
$up[] = $this->buildAddIndex($tableName, $name, $index);
$down[] = $this->buildRemoveIndex($tableName, $name, $index);
}

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Query.php 5876 2009-06-10 18:43:12Z piccoloprincipe $
* $Id: Query.php 6138 2009-07-21 15:20:59Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -30,7 +30,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5876 $
* @version $Revision: 6138 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Proposal: This class does far too much. It should have only 1 task: Collecting
* the DQL query parts and the query parameters (the query state and caching options/methods
@ -527,12 +527,12 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
$parent = $this->_conn->getTable($owner);
$columnName = $parent->getColumnName($fieldName);
$parentAlias = $this->getTableAlias($componentAlias . '.' . $parent->getComponentName());
$sql[] = $this->_conn->quoteIdentifier($parentAlias . '.' . $columnName)
$sql[] = $this->_conn->quoteIdentifier($parentAlias) . '.' . $this->_conn->quoteIdentifier($columnName)
. ' AS '
. $this->_conn->quoteIdentifier($tableAlias . '__' . $columnName);
} else {
$columnName = $table->getColumnName($fieldName);
$sql[] = $this->_conn->quoteIdentifier($tableAlias . '.' . $columnName)
$sql[] = $this->_conn->quoteIdentifier($tableAlias) . '.' . $this->_conn->quoteIdentifier($columnName)
. ' AS '
. $this->_conn->quoteIdentifier($tableAlias . '__' . $columnName);
}

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Groupby.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
* $Id: Groupby.php 5975 2009-07-01 03:50:26Z guilhermeblanco $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -27,7 +27,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @version $Revision: 5975 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Query_Groupby extends Doctrine_Query_Part
@ -152,7 +152,7 @@ class Doctrine_Query_Groupby extends Doctrine_Query_Part
. '.' . $conn->quoteIdentifier($term[0]);
} else {
// build sql expression
$term[0] = $this->_conn->quoteIdentifier($term[0]);
$term[0] = $conn->quoteIdentifier($term[0]);
}
} else {
$found = false;

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Orderby.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
* $Id: Orderby.php 5975 2009-07-01 03:50:26Z guilhermeblanco $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -27,7 +27,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @version $Revision: 5975 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Query_Orderby extends Doctrine_Query_Part
@ -152,7 +152,7 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part
. '.' . $conn->quoteIdentifier($term[0]);
} else {
// build sql expression
$term[0] = $this->_conn->quoteIdentifier($term[0]);
$term[0] = $conn->quoteIdentifier($term[0]);
}
} else {
$found = false;

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Record.php 5876 2009-06-10 18:43:12Z piccoloprincipe $
* $Id: Record.php 6163 2009-07-24 19:53:47Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -29,7 +29,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5876 $
* @version $Revision: 6163 $
*/
abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Countable, IteratorAggregate, Serializable
{
@ -1790,8 +1790,11 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$columnValue = $this->get($column);
$a[$column] = ($columnValue instanceof Doctrine_Record)
? $columnValue->toArray($deep, $prefixKey) : $columnValue;
if ($columnValue instanceof Doctrine_Record) {
$a[$column] = $columnValue->getIncremented();
} else {
$a[$column] = $columnValue;
}
}
if ($this->_table->getIdentifierType() == Doctrine::IDENTIFIER_AUTOINC) {
@ -1872,7 +1875,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this->$key->fromArray($value, $deep);
}
}
} else if ($this->getTable()->hasField($key)) {
} else if ($this->getTable()->hasField($key) || array_key_exists($key, $this->_values)) {
$this->set($key, $value);
} else {
$method = 'set' . Doctrine_Inflector::classify($key);

View File

@ -295,9 +295,9 @@ abstract class Doctrine_Record_Generator extends Doctrine_Record_Abstract
{
$options = array('local' => $this->_options['table']->getIdentifier(),
'foreign' => $this->_options['table']->getIdentifier(),
'type' => Doctrine_Relation::MANY);
'type' => Doctrine_Relation::ONE,
'owningSide' => true);
$options['type'] = Doctrine_Relation::ONE;
$options['onDelete'] = 'CASCADE';
$options['onUpdate'] = 'CASCADE';

View File

@ -107,7 +107,8 @@ class Doctrine_Relation_Nest extends Doctrine_Relation_Association
}
$q->select('{'.$tableName.'.*}, {'.$assocTable.'.*}')
->from($tableName . ' INNER JOIN ' . $assocTable . ' ON ' . implode(' OR ', $joinCondition))
->where(implode(' OR ', $condition));
->where(implode(' OR ', $condition))
->orderBy($tableName . '.' . $identifier . ' ASC');
$q->addComponent($tableName, $this->getClass());
$path = $this->getClass(). '.' . $this->getAssociationFactory()->getComponentName();

View File

@ -179,14 +179,14 @@ class Doctrine_Search extends Doctrine_Record_Generator
$conn = $this->_options['table']->getConnection();
$tableName = $this->_options['table']->getTableName();
$id = $this->_options['table']->getIdentifier();
$id = current($this->_options['table']->getIdentifierColumnNames());
$query = 'SELECT * FROM ' . $conn->quoteIdentifier($tableName)
. ' WHERE ' . $conn->quoteIdentifier($id)
. ' IN (SELECT ' . $conn->quoteIdentifier($id)
. ' IN (SELECT ' . $conn->quoteIdentifier('id')
. ' FROM ' . $conn->quoteIdentifier($this->_table->getTableName())
. ' WHERE keyword IS NULL) OR ' . $conn->quoteIdentifier($id)
. ' NOT IN (SELECT ' . $conn->quoteIdentifier($id)
. ' WHERE keyword = \'\') OR ' . $conn->quoteIdentifier($id)
. ' NOT IN (SELECT ' . $conn->quoteIdentifier('id')
. ' FROM ' . $conn->quoteIdentifier($this->_table->getTableName()) . ')';
$query = $conn->modifyLimitQuery($query, $limit, $offset);
@ -203,15 +203,18 @@ class Doctrine_Search extends Doctrine_Record_Generator
*/
public function batchUpdateIndex($limit = null, $offset = null, $encoding = null)
{
$this->initialize($this->_options['table']);
$table = $this->_options['table'];
$id = $this->_options['table']->getIdentifier();
$this->initialize($table);
$id = current($table->getIdentifierColumnNames());
$class = $this->_options['className'];
$fields = $this->_options['fields'];
$conn = $this->_options['connection'];
try {
$conn->beginTransaction();
for ($i = 0; $i < count($fields); $i++) {
$fields[$i] = $table->getColumnName($fields[$i], $fields[$i]);
}
$rows = $this->readTableData($limit, $offset);
@ -220,16 +223,21 @@ class Doctrine_Search extends Doctrine_Record_Generator
$ids[] = $row[$id];
}
if (count($ids) > 0)
{
$placeholders = str_repeat('?, ', count($ids));
$placeholders = substr($placeholders, 0, strlen($placeholders) - 2);
$sql = 'DELETE FROM '
. $conn->quoteIdentifier($this->_table->getTableName())
. ' WHERE ' . $conn->quoteIdentifier($id) . ' IN (' . substr($placeholders, 0) . ')';
. ' WHERE ' . $conn->quoteIdentifier($table->getIdentifier()) . ' IN (' . substr($placeholders, 0) . ')';
$conn->exec($sql, $ids);
}
foreach ($rows as $row) {
$conn->beginTransaction();
try {
foreach ($fields as $field) {
$data = $row[$field];
@ -242,18 +250,18 @@ class Doctrine_Search extends Doctrine_Record_Generator
$index->position = $pos;
$index->field = $field;
foreach ((array) $id as $identifier) {
$index->$identifier = $row[$identifier];
foreach ((array) $table->getIdentifier() as $identifier) {
$index->$identifier = $row[$table->getColumnName($identifier, $identifier)];
}
$index->save();
}
}
}
$conn->commit();
} catch (Doctrine_Exception $e) {
$conn->rollback();
throw $e;
}
}
}

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Table.php 5876 2009-06-10 18:43:12Z piccoloprincipe $
* $Id: Table.php 6051 2009-07-10 17:53:44Z dcousineau $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -28,7 +28,7 @@
* @package Doctrine
* @subpackage Table
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision: 5876 $
* @version $Revision: 6051 $
* @link www.phpdoctrine.org
* @since 1.0
* @method mixed findBy*(mixed $value) magic finders; @see __call()
@ -695,24 +695,19 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
'foreign' => $relation->getForeignColumnName(),
'foreignTable' => $relation->getTable()->getTableName());
if (($key = array_search($def, $options['foreignKeys'])) === false) {
if ($integrity !== $emptyIntegrity) {
$def = array_merge($def, $integrity);
}
if (($key = $this->_checkForeignKeyExists($def, $options['foreignKeys'])) === false) {
$options['foreignKeys'][$fkName] = $def;
if ($integrity !== $emptyIntegrity) {
$constraints[$fkName] = $integrity;
}
} else {
if ($integrity !== $emptyIntegrity) {
$constraints[$key] = $integrity;
unset($def['name']);
$options['foreignKeys'][$key] = array_merge($options['foreignKeys'][$key], $def);
}
}
}
}
foreach ($constraints as $k => $def) {
$options['foreignKeys'][$k] = array_merge($options['foreignKeys'][$k], $def);
}
}
$options['primary'] = $primary;
return array('tableName' => $this->getOption('tableName'),
@ -720,6 +715,24 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
'options' => array_merge($this->getOptions(), $options));
}
/**
* Check if a foreign definition already exists in the fks array for a
* foreign table, local and foreign key
*
* @param array $def Foreign key definition to check for
* @param array $foreignKeys Array of existing foreign key definitions to check in
* @return boolean $result Whether or not the foreign key was found
*/
protected function _checkForeignKeyExists($def, $foreignKeys)
{
foreach ($foreignKeys as $key => $foreignKey) {
if ($def['local'] == $foreignKey['local'] && $def['foreign'] == $foreignKey['foreign'] && $def['foreignTable'] == $foreignKey['foreignTable']) {
return $key;
}
}
return false;
}
/**
* Retrieves the relation parser associated with this table.
*
@ -1172,8 +1185,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
case 'object':
case 'blob':
case 'gzip':
// use php int max
$length = 2147483647;
//$length = 2147483647;
//All the DataDict driver classes have work-arounds to deal
//with unset lengths.
$length = null;
break;
case 'boolean':
$length = 1;

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: Validator.php 5814 2009-06-03 16:26:59Z jwage $
* $Id: Validator.php 6051 2009-07-10 17:53:44Z dcousineau $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -27,7 +27,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5814 $
* @version $Revision: 6051 $
* @author Roman Borschel <roman@code-factory.org>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
@ -89,6 +89,9 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
*/
public static function validateLength($value, $type, $maximumLength)
{
if( $maximumLength === null ) {
return true;
}
if ($type == 'timestamp' || $type == 'integer' || $type == 'enum') {
return true;
} else if ($type == 'array' || $type == 'object') {

View File

@ -1,6 +1,6 @@
<?php
/*
* $Id: View.php 5798 2009-06-02 15:10:46Z piccoloprincipe $
* $Id: View.php 6162 2009-07-24 19:39:27Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -30,7 +30,7 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 5798 $
* @version $Revision: 6162 $
*/
class Doctrine_View
{
@ -129,7 +129,7 @@ class Doctrine_View
{
$sql = sprintf(self::CREATE, $this->_name, $this->_query->getQuery());
try {
$this->_conn->execute($sql);
$this->_conn->execute($sql, $this->_query->getFlattenedParams());
} catch(Doctrine_Exception $e) {
throw new Doctrine_View_Exception($e->__toString());
}