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