CustomPrimaryKeyTestCase added
This commit is contained in:
parent
990548d315
commit
a20d0544dd
10 changed files with 144 additions and 8 deletions
25
Doctrine.php
25
Doctrine.php
|
@ -1,11 +1,32 @@
|
|||
<?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");
|
||||
|
||||
/**
|
||||
* Doctrine
|
||||
* the base class of Doctrine framework
|
||||
*
|
||||
* @package Doctrine ORM
|
||||
* @url www.phpdoctrine.com
|
||||
* @package Doctrine
|
||||
* @author Konsta Vesterinen
|
||||
* @license LGPL
|
||||
*/
|
||||
final class Doctrine {
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
<?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
|
||||
* Collection of Doctrine_Record objects.
|
||||
|
|
|
@ -1,4 +1,23 @@
|
|||
<?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
|
||||
* iterates through Doctrine_Collection
|
||||
|
|
|
@ -1,8 +1,35 @@
|
|||
<?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");
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
?>
|
||||
|
|
|
@ -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 <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'.
|
26
tests/CustomPrimaryKeyTestCase.php
Normal file
26
tests/CustomPrimaryKeyTestCase.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?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 {
|
|||
$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");
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue