From a20d0544dda2281b7f16e5e5f772611c143eaaa8 Mon Sep 17 00:00:00 2001 From: doctrine Date: Wed, 26 Jul 2006 17:09:00 +0000 Subject: [PATCH] CustomPrimaryKeyTestCase added --- Doctrine.php | 25 +++++++++++++++-- Doctrine/Collection.php | 21 ++++++++++++++- Doctrine/Iterator.php | 19 +++++++++++++ Doctrine/Record.php | 27 +++++++++++++++++++ ...omponents - Locking Manager - Examples.php | 12 ++++++--- ...omponents - Query - Method overloading.php | 10 ++++++- ...ents - Query - FROM - selecting tables.php | 3 +++ tests/CustomPrimaryKeyTestCase.php | 26 ++++++++++++++++++ tests/classes.php | 6 +++++ tests/run.php | 3 +++ 10 files changed, 144 insertions(+), 8 deletions(-) create mode 100644 manual/docs/Basic Components - Query - FROM - selecting tables.php create mode 100644 tests/CustomPrimaryKeyTestCase.php diff --git a/Doctrine.php b/Doctrine.php index 0997ff058..610ae41cd 100644 --- a/Doctrine.php +++ b/Doctrine.php @@ -1,11 +1,32 @@ . + */ + require_once("Doctrine/Exception.php"); + /** * Doctrine * the base class of Doctrine framework * - * @package Doctrine ORM - * @url www.phpdoctrine.com + * @package Doctrine + * @author Konsta Vesterinen * @license LGPL */ final class Doctrine { diff --git a/Doctrine/Collection.php b/Doctrine/Collection.php index fd2401127..d30b9ea56 100644 --- a/Doctrine/Collection.php +++ b/Doctrine/Collection.php @@ -1,5 +1,24 @@ . + */ +Doctrine::autoload("Access"); /** * Doctrine_Collection * Collection of Doctrine_Record objects. diff --git a/Doctrine/Iterator.php b/Doctrine/Iterator.php index 61246fa3f..5776e86f5 100644 --- a/Doctrine/Iterator.php +++ b/Doctrine/Iterator.php @@ -1,4 +1,23 @@ . + */ /** * Doctrine_Iterator * iterates through Doctrine_Collection diff --git a/Doctrine/Record.php b/Doctrine/Record.php index 8880cdf26..0b4ca7ec2 100644 --- a/Doctrine/Record.php +++ b/Doctrine/Record.php @@ -1,8 +1,35 @@ . + */ + require_once("Access.php"); + /** * Doctrine_Record + * All record classes should inherit this super class + * + * @author Konsta Vesterinen + * @license LGPL + * @package Doctrine */ + abstract class Doctrine_Record extends Doctrine_Access implements Countable, IteratorAggregate, Serializable { /** * STATE CONSTANTS diff --git a/manual/codes/Advanced components - Locking Manager - Examples.php b/manual/codes/Advanced components - Locking Manager - Examples.php index 22afb7c53..0f2407697 100644 --- a/manual/codes/Advanced components - Locking Manager - Examples.php +++ b/manual/codes/Advanced components - Locking Manager - Examples.php @@ -6,13 +6,17 @@ $lockingMngr = new Doctrine_Locking_Manager_Pessimistic(); try { - // Ensure that old locks which timed out are released before we try to acquire our lock - $lockingMngr->releaseAgedLocks(300); // 300 seconds = 5 minutes timeout + // Ensure that old locks which timed out are released + // before we try to acquire our lock + // 300 seconds = 5 minutes timeout + $lockingMngr->releaseAgedLocks(300); // Try to get the lock on a record $gotLock = $lockingMngr->getLock( - $myRecordToLock, // The record to lock. This can be any Doctrine_Record - 'Bart Simpson' // The unique identifier of the user who is trying to get the lock + // The record to lock. This can be any Doctrine_Record + $myRecordToLock, + // The unique identifier of the user who is trying to get the lock + 'Bart Simpson' ); if($gotLock) diff --git a/manual/codes/Basic Components - Query - Method overloading.php b/manual/codes/Basic Components - Query - Method overloading.php index 33d39bad7..1245b7ca3 100644 --- a/manual/codes/Basic Components - Query - Method overloading.php +++ b/manual/codes/Basic Components - Query - Method overloading.php @@ -5,8 +5,16 @@ $query = new Doctrine_Query($session); $query->from("User-b") ->where("User.name LIKE 'Jack%'") - ->orderby("User.created"); + ->orderby("User.created") ->limit(5); +$users = $query->execute(); + +$query->from("User.Group.Phonenumber") + ->where("User.Group.name LIKE 'Actors%'") + ->orderby("User.name") + ->limit(10) + ->offset(5); + $users = $query->execute(); ?> diff --git a/manual/docs/Basic Components - Query - FROM - selecting tables.php b/manual/docs/Basic Components - Query - FROM - selecting tables.php new file mode 100644 index 000000000..de4d393c4 --- /dev/null +++ b/manual/docs/Basic Components - Query - FROM - selecting tables.php @@ -0,0 +1,3 @@ +DQL FROM -part is used for selecting tables as well as for selecting fields. Related components are selected either +with colon-operator or dot-operator (See Relation operators).
You can place +the selected fields in () -brackets (eg. 'FROM User(name, id)'). If you are about to select all fields you can simple use 'FROM User'. diff --git a/tests/CustomPrimaryKeyTestCase.php b/tests/CustomPrimaryKeyTestCase.php new file mode 100644 index 000000000..b3e221936 --- /dev/null +++ b/tests/CustomPrimaryKeyTestCase.php @@ -0,0 +1,26 @@ +tables = array("CustomPK"); + } + public function testOperations() { + $c = new CustomPK(); + $this->assertTrue($c instanceof Doctrine_Record); + + $c->name = "custom pk test"; + $this->assertEqual($c->getID(), array()); + + $c->save(); + $this->assertEqual($c->getID(), array("uid" => 1)); + $this->session->clear(); + + $c = $this->session->getTable('CustomPK')->find(1); + + $this->assertEqual($c->getID(), array("uid" => 1)); + } +} +?> diff --git a/tests/classes.php b/tests/classes.php index 52ebf78ff..ee43ecde1 100644 --- a/tests/classes.php +++ b/tests/classes.php @@ -319,6 +319,12 @@ class EnumTest extends Doctrine_Record { $this->setEnumValues("status", array("open","verified","closed")); } } +class CustomPK extends Doctrine_Record { + public function setTableDefinition() { + $this->hasColumn("uid","integer",11,"autoincrement|primary"); + $this->hasColumn("name","string",255); + } +} class Log_Entry extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn("stamp", "timestamp"); diff --git a/tests/run.php b/tests/run.php index af8876434..91fc36763 100644 --- a/tests/run.php +++ b/tests/run.php @@ -20,6 +20,7 @@ require_once("QueryTestCase.php"); require_once("CacheQuerySqliteTestCase.php"); require_once("ViewTestCase.php"); require_once("RawSqlTestCase.php"); +require_once("CustomPrimaryKeyTestCase.php"); error_reporting(E_ALL); @@ -57,6 +58,8 @@ $test->addTestCase(new Doctrine_QueryTestCase()); $test->addTestCase(new Doctrine_RawSql_TestCase()); +$test->addTestCase(new Doctrine_CustomPrimaryKeyTestCase()); + //$test->addTestCase(new Doctrine_Cache_FileTestCase()); //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());