Commit a20d0544 authored by doctrine's avatar doctrine

CustomPrimaryKeyTestCase added

parent 990548d3
<?php <?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>.
*/
require_once("Doctrine/Exception.php"); require_once("Doctrine/Exception.php");
/** /**
* Doctrine * Doctrine
* the base class of Doctrine framework * the base class of Doctrine framework
* *
* @package Doctrine ORM * @package Doctrine
* @url www.phpdoctrine.com * @author Konsta Vesterinen
* @license LGPL * @license LGPL
*/ */
final class Doctrine { final class Doctrine {
......
<?php <?php
require_once("Access.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::autoload("Access");
/** /**
* Doctrine_Collection * Doctrine_Collection
* Collection of Doctrine_Record objects. * Collection of Doctrine_Record objects.
......
<?php <?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_Iterator * Doctrine_Iterator
* iterates through Doctrine_Collection * iterates through Doctrine_Collection
......
<?php <?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>.
*/
require_once("Access.php"); require_once("Access.php");
/** /**
* Doctrine_Record * 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 { abstract class Doctrine_Record extends Doctrine_Access implements Countable, IteratorAggregate, Serializable {
/** /**
* STATE CONSTANTS * STATE CONSTANTS
......
...@@ -6,13 +6,17 @@ $lockingMngr = new Doctrine_Locking_Manager_Pessimistic(); ...@@ -6,13 +6,17 @@ $lockingMngr = new Doctrine_Locking_Manager_Pessimistic();
try try
{ {
// Ensure that old locks which timed out are released before we try to acquire our lock // Ensure that old locks which timed out are released
$lockingMngr->releaseAgedLocks(300); // 300 seconds = 5 minutes timeout // before we try to acquire our lock
// 300 seconds = 5 minutes timeout
$lockingMngr->releaseAgedLocks(300);
// Try to get the lock on a record // Try to get the lock on a record
$gotLock = $lockingMngr->getLock( $gotLock = $lockingMngr->getLock(
$myRecordToLock, // The record to lock. This can be any Doctrine_Record // 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 $myRecordToLock,
// The unique identifier of the user who is trying to get the lock
'Bart Simpson'
); );
if($gotLock) if($gotLock)
......
...@@ -5,8 +5,16 @@ $query = new Doctrine_Query($session); ...@@ -5,8 +5,16 @@ $query = new Doctrine_Query($session);
$query->from("User-b") $query->from("User-b")
->where("User.name LIKE 'Jack%'") ->where("User.name LIKE 'Jack%'")
->orderby("User.created"); ->orderby("User.created")
->limit(5); ->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(); $users = $query->execute();
?> ?>
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 <a href="documentation.php?index=2.8.php">Relation operators</a>). <br \>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'.
<?php
require_once("UnitTestCase.php");
class Doctrine_CustomPrimaryKeyTestCase extends Doctrine_UnitTestCase {
public function prepareData() { }
public function prepareTables() {
$this->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));
}
}
?>
...@@ -319,6 +319,12 @@ class EnumTest extends Doctrine_Record { ...@@ -319,6 +319,12 @@ class EnumTest extends Doctrine_Record {
$this->setEnumValues("status", array("open","verified","closed")); $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 { class Log_Entry extends Doctrine_Record {
public function setTableDefinition() { public function setTableDefinition() {
$this->hasColumn("stamp", "timestamp"); $this->hasColumn("stamp", "timestamp");
......
...@@ -20,6 +20,7 @@ require_once("QueryTestCase.php"); ...@@ -20,6 +20,7 @@ require_once("QueryTestCase.php");
require_once("CacheQuerySqliteTestCase.php"); require_once("CacheQuerySqliteTestCase.php");
require_once("ViewTestCase.php"); require_once("ViewTestCase.php");
require_once("RawSqlTestCase.php"); require_once("RawSqlTestCase.php");
require_once("CustomPrimaryKeyTestCase.php");
error_reporting(E_ALL); error_reporting(E_ALL);
...@@ -57,6 +58,8 @@ $test->addTestCase(new Doctrine_QueryTestCase()); ...@@ -57,6 +58,8 @@ $test->addTestCase(new Doctrine_QueryTestCase());
$test->addTestCase(new Doctrine_RawSql_TestCase()); $test->addTestCase(new Doctrine_RawSql_TestCase());
$test->addTestCase(new Doctrine_CustomPrimaryKeyTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase()); //$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase()); //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
......
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