Commit 827755af authored by zYne's avatar zYne

--no commit message

--no commit message
parent 82ba74e2
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -555,12 +555,20 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator ...@@ -555,12 +555,20 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/ */
public function processDiff() public function processDiff()
{ {
foreach (array_diff($this->_snapshot, $this->data) as $record) { foreach (array_diff($this->_snapshot, $this->data) as $record) {
$record->delete(); $record->delete();
} }
return $this; return $this;
} }
public function getDeleteDiff()
{
return array_diff($this->_snapshot, $this->data);
}
public function getInsertDiff()
{
return array_diff($this->data, $this->_snapshot);
}
/** /**
* save * save
* saves all records of this collection and processes the * saves all records of this collection and processes the
......
...@@ -785,8 +785,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -785,8 +785,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
} }
$tableObject->getRelations(); $tableObject->getRelations();
//$this->getTable('RelationTestChild')->getRelation('Children');
} }
$next = count($this->tables); $next = count($this->tables);
} }
......
...@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_Connection_Module'); ...@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_Connection_Module');
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implements IteratorAggregate, Countable class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
{ {
/** /**
* buildFlushTree * buildFlushTree
...@@ -163,6 +163,20 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen ...@@ -163,6 +163,20 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
} }
} elseif ($fk instanceof Doctrine_Relation_Association) { } elseif ($fk instanceof Doctrine_Relation_Association) {
$assocTable = $fk->getAssociationTable();
foreach ($v->getDeleteDiff() as $r) {
$query = 'DELETE FROM ' . $assocTable->getTableName()
. ' WHERE ' . $fk->getForeign() . ' = ?'
. ' AND ' . $fk->getLocal() . ' = ?';
$this->query($r->getIncremented(), $record->getIncremented());
}
foreach ($v->getInsertDiff as $r) {
$assocRecord = $assocTable->create();
$assocRecord->set($fk->getForeign(), $r);
$assocRecord->set($fk->getLocal(), $record);
$assocRecord->save($this->conn);
}
$v->save($this->conn); $v->save($this->conn);
} }
} }
...@@ -186,8 +200,10 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen ...@@ -186,8 +200,10 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
public function saveAssociations(Doctrine_Record $record) public function saveAssociations(Doctrine_Record $record)
{ {
foreach ($record->getTable()->getRelations() as $rel) { foreach ($record->getTable()->getRelations() as $rel) {
$table = $rel->getTable(); $table = $rel->getTable();
$alias = $rel->getAlias(); $alias = $rel->getAlias();
} }
} }
/** /**
...@@ -206,7 +222,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen ...@@ -206,7 +222,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
$obj = $record->get($fk->getAlias()); $obj = $record->get($fk->getAlias());
$obj->delete($this->conn); $obj->delete($this->conn);
break; break;
}; }
} }
} }
/** /**
...@@ -347,9 +363,4 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen ...@@ -347,9 +363,4 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
return true; return true;
} }
public function getIterator()
{ }
public function count()
{ }
} }
...@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_Hydrate'); ...@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_Hydrate');
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Query extends Doctrine_Hydrate implements Countable class Doctrine_Query extends Doctrine_Hydrate implements Countable
{ {
/** /**
* @param array $subqueryAliases the table aliases needed in some LIMIT subqueries * @param array $subqueryAliases the table aliases needed in some LIMIT subqueries
...@@ -205,7 +205,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable ...@@ -205,7 +205,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable
*/ */
public function parseSelect($dql) public function parseSelect($dql)
{ {
$refs = Doctrine_Query::bracketExplode($dql, ','); $refs = Doctrine_Tokenizer::bracketExplode($dql, ',');
foreach ($refs as $reference) { foreach ($refs as $reference) {
if (strpos($reference, '(') !== false) { if (strpos($reference, '(') !== false) {
...@@ -237,7 +237,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable ...@@ -237,7 +237,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable
*/ */
public function parseSubselect($reference) public function parseSubselect($reference)
{ {
$e = Doctrine_Query::bracketExplode($reference, ' '); $e = Doctrine_Tokenizer::bracketExplode($reference, ' ');
$alias = $e[1]; $alias = $e[1];
if (count($e) > 2) { if (count($e) > 2) {
...@@ -253,7 +253,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable ...@@ -253,7 +253,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable
} }
public function parseAggregateFunction2($func) public function parseAggregateFunction2($func)
{ {
$e = Doctrine_Query::bracketExplode($func, ' '); $e = Doctrine_Tokenizer::bracketExplode($func, ' ');
$func = $e[0]; $func = $e[0];
$pos = strpos($func, '('); $pos = strpos($func, '(');
......
...@@ -83,7 +83,7 @@ class Doctrine_Query_Check ...@@ -83,7 +83,7 @@ class Doctrine_Query_Check
*/ */
public function parseClause($dql) public function parseClause($dql)
{ {
$parts = Doctrine_Query::sqlExplode($dql, ' AND '); $parts = Doctrine_Tokenizer::sqlExplode($dql, ' AND ');
if (count($parts) > 1) { if (count($parts) > 1) {
$ret = array(); $ret = array();
...@@ -93,7 +93,7 @@ class Doctrine_Query_Check ...@@ -93,7 +93,7 @@ class Doctrine_Query_Check
$r = implode(' AND ', $ret); $r = implode(' AND ', $ret);
} else { } else {
$parts = Doctrine_Query::quoteExplode($dql, ' OR '); $parts = Doctrine_Tokenizer::quoteExplode($dql, ' OR ');
if (count($parts) > 1) { if (count($parts) > 1) {
$ret = array(); $ret = array();
foreach ($parts as $part) { foreach ($parts as $part) {
......
...@@ -42,6 +42,10 @@ class Doctrine_Relation_Association extends Doctrine_Relation ...@@ -42,6 +42,10 @@ class Doctrine_Relation_Association extends Doctrine_Relation
{ {
return $this->definition['assocTable']; return $this->definition['assocTable'];
} }
public function getAssociationTable()
{
return $this->definition['assocTable'];
}
/** /**
* processDiff * processDiff
* *
......
...@@ -19,12 +19,6 @@ ...@@ -19,12 +19,6 @@
* <http://www.phpdoctrine.com>. * <http://www.phpdoctrine.com>.
*/ */
require_once('../draft/new-core/Record.php');
require_once('../draft/new-core/Hydrate.php');
require_once('../draft/new-core/Query.php');
require_once('../draft/new-core/Collection.php');
/** /**
* Doctrine_Hydrate_TestCase * Doctrine_Hydrate_TestCase
* *
...@@ -36,8 +30,6 @@ require_once('../draft/new-core/Collection.php'); ...@@ -36,8 +30,6 @@ require_once('../draft/new-core/Collection.php');
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
*/ */
class Doctrine_Hydrate_TestCase extends Doctrine_UnitTestCase class Doctrine_Hydrate_TestCase extends Doctrine_UnitTestCase
{ {
protected $testData1 = array( protected $testData1 = array(
......
...@@ -31,14 +31,14 @@ ...@@ -31,14 +31,14 @@
* @version $Revision$ * @version $Revision$
*/ */
class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
/**
public function prepareTables() { public function prepareTables() {
$this->tables[] = "enumTest"; $this->tables[] = "enumTest";
$this->tables[] = "fieldNameTest"; $this->tables[] = "fieldNameTest";
$this->tables[] = "GzipTest"; $this->tables[] = "GzipTest";
parent::prepareTables(); parent::prepareTables();
} }
*/
public function testIssetForPrimaryKey() { public function testIssetForPrimaryKey() {
$this->assertTrue(isset($this->users[0]->id)); $this->assertTrue(isset($this->users[0]->id));
$this->assertTrue(isset($this->users[0]['id'])); $this->assertTrue(isset($this->users[0]['id']));
...@@ -50,7 +50,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { ...@@ -50,7 +50,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertFalse(isset($user['id'])); $this->assertFalse(isset($user['id']));
$this->assertFalse($user->contains('id')); $this->assertFalse($user->contains('id'));
} }
/**
public function testUnknownColumn() { public function testUnknownColumn() {
} }
...@@ -299,14 +299,6 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { ...@@ -299,14 +299,6 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($user->name, null); $this->assertEqual($user->name, null);
} }
public function testDateTimeType() {
$date = new DateTest();
}
public function testSerialize() { public function testSerialize() {
$user = $this->connection->getTable("User")->find(4); $user = $this->connection->getTable("User")->find(4);
$str = serialize($user); $str = serialize($user);
...@@ -324,9 +316,6 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { ...@@ -324,9 +316,6 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$user->call('substr', 'name', 0, 1); $user->call('substr', 'name', 0, 1);
$this->assertEqual($user->name, 'z'); $this->assertEqual($user->name, 'z');
} }
public function testCompositePK() { public function testCompositePK() {
$record = new EntityReference(); $record = new EntityReference();
$this->assertEqual($record->getTable()->getIdentifier(), array("entity1","entity2")); $this->assertEqual($record->getTable()->getIdentifier(), array("entity1","entity2"));
...@@ -711,8 +700,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { ...@@ -711,8 +700,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($new->loginname, 'jackd'); $this->assertEqual($new->loginname, 'jackd');
} }
public function testReferences() { public function testReferences()
{
$user = $this->objTable->find(5); $user = $this->objTable->find(5);
$pf = $this->connection->getTable("Phonenumber"); $pf = $this->connection->getTable("Phonenumber");
...@@ -946,13 +935,15 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { ...@@ -946,13 +935,15 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testCount() { public function testCount()
{
$user = $this->connection->getTable("User")->find(4); $user = $this->connection->getTable("User")->find(4);
$this->assertTrue(is_integer($user->count())); $this->assertTrue(is_integer($user->count()));
} }
public function testGetReference() { public function testGetReference()
{
$user = $this->connection->getTable("User")->find(4); $user = $this->connection->getTable("User")->find(4);
$this->assertTrue($user->Email instanceof Doctrine_Record); $this->assertTrue($user->Email instanceof Doctrine_Record);
...@@ -961,10 +952,10 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { ...@@ -961,10 +952,10 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertTrue($user->Phonenumber->count() == 1); $this->assertTrue($user->Phonenumber->count() == 1);
} }
public function testGetIterator() { public function testGetIterator()
{
$user = $this->connection->getTable("User")->find(4); $user = $this->connection->getTable("User")->find(4);
$this->assertTrue($user->getIterator() instanceof ArrayIterator); $this->assertTrue($user->getIterator() instanceof ArrayIterator);
} }
*/
} }
?> ?>
...@@ -228,10 +228,10 @@ class Doctrine_UnitTestCase extends UnitTestCase { ...@@ -228,10 +228,10 @@ class Doctrine_UnitTestCase extends UnitTestCase {
} }
} }
public function setUp() { public function setUp() {
if( ! $this->init) $this->init(); if ( ! $this->init) {
$this->init();
if(isset($this->objTable)) }
$this->objTable->clear(); $this->objTable->clear();
$this->init = true; $this->init = true;
} }
......
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