Some new manual code examples
This commit is contained in:
parent
b7bf2265ef
commit
ae738ccb97
@ -32,6 +32,7 @@ class Doctrine_Form implements Iterator {
|
|||||||
if( ! in_array("autoincrement",$e) && ! in_array("protected",$e)) {
|
if( ! in_array("autoincrement",$e) && ! in_array("protected",$e)) {
|
||||||
if($enum) {
|
if($enum) {
|
||||||
$elements[$column] = "<select name='data[$column]'>\n";
|
$elements[$column] = "<select name='data[$column]'>\n";
|
||||||
|
$elements[$column] .= " <option value='-'>-</option>\n";
|
||||||
foreach($enum as $k => $v) {
|
foreach($enum as $k => $v) {
|
||||||
if($this->record->get($column) == $v) {
|
if($this->record->get($column) == $v) {
|
||||||
$str = 'selected';
|
$str = 'selected';
|
||||||
|
@ -1,6 +1,33 @@
|
|||||||
<?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::autoload('Doctrine_Access');
|
Doctrine::autoload('Doctrine_Access');
|
||||||
|
/**
|
||||||
|
* Doctrine_Hydrate is a base class for Doctrine_RawSql and Doctrine_Query.
|
||||||
|
* Its purpose is to populate object graphs.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package Doctrine ORM
|
||||||
|
* @url www.phpdoctrine.com
|
||||||
|
* @license LGPL
|
||||||
|
*/
|
||||||
class Doctrine_Hydrate extends Doctrine_Access {
|
class Doctrine_Hydrate extends Doctrine_Access {
|
||||||
/**
|
/**
|
||||||
* @var array $fetchmodes an array containing all fetchmodes
|
* @var array $fetchmodes an array containing all fetchmodes
|
||||||
|
@ -1,4 +1,23 @@
|
|||||||
<?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::autoload('Doctrine_Iterator');
|
Doctrine::autoload('Doctrine_Iterator');
|
||||||
|
|
||||||
class Doctrine_Iterator_Normal extends Doctrine_Iterator {
|
class Doctrine_Iterator_Normal extends Doctrine_Iterator {
|
||||||
|
@ -1,7 +1,26 @@
|
|||||||
<?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_Validator
|
* Doctrine_Validator
|
||||||
* Doctrine_Session uses this class for transaction validation
|
* Doctrine_Validator performs validations in record properties
|
||||||
*
|
*
|
||||||
* @package Doctrine ORM
|
* @package Doctrine ORM
|
||||||
* @url www.phpdoctrine.com
|
* @url www.phpdoctrine.com
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
class Groupuser extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn("user_id", "integer" 20, "primary");
|
||||||
|
$this->hasColumn("group_id", "integer", 20, "primary");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class User extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
$this->hasColumn("name","string",200,"primary");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
class Article extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
// few mapping examples:
|
||||||
|
|
||||||
|
// maps into VARCHAR(100) on mysql
|
||||||
|
$this->hasColumn("title","string",100);
|
||||||
|
|
||||||
|
// maps into TEXT on mysql
|
||||||
|
$this->hasColumn("content","string",4000);
|
||||||
|
|
||||||
|
// maps into TINYINT on mysql
|
||||||
|
$this->hasColumn("type","integer",1);
|
||||||
|
|
||||||
|
// maps into INT on mysql
|
||||||
|
$this->hasColumn("type2","integer",11);
|
||||||
|
|
||||||
|
// maps into BIGINT on mysql
|
||||||
|
$this->hasColumn("type3","integer",20);
|
||||||
|
|
||||||
|
// maps into TEXT on mysql
|
||||||
|
// (serialized and unserialized automatically by doctrine)
|
||||||
|
$this->hasColumn("types","array",4000);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
class Email extends Doctrine_Record {
|
||||||
|
public function setTableDefinition() {
|
||||||
|
// setting custom table name:
|
||||||
|
$this->setTableName('emails');
|
||||||
|
|
||||||
|
$this->hasColumn("address", // name of the column
|
||||||
|
"string", // column type
|
||||||
|
"200", // column length
|
||||||
|
"notblank|email" // validators / constraints
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -2,9 +2,9 @@ Doctrine_Record is the basic component of every doctrine-based project.
|
|||||||
There should be atleast one Doctrine_Record for each of your database tables.
|
There should be atleast one Doctrine_Record for each of your database tables.
|
||||||
Doctrine_Record follows <a href="http://www.martinfowler.com/eaaCatalog/activeRecord.html">Active Record pattern</a>.
|
Doctrine_Record follows <a href="http://www.martinfowler.com/eaaCatalog/activeRecord.html">Active Record pattern</a>.
|
||||||
<br \><br \>
|
<br \><br \>
|
||||||
Doctrine auto-creates database tables and always adds a primary key column named 'id' to tables. Only thing you need to for creating database tables
|
Doctrine auto-creates database tables and always adds a primary key column named 'id' to tables that doesn't have any primary keys specified. Only thing you need to for creating database tables
|
||||||
is defining a class which extends Doctrine_Record and setting a setTableDefinition method with hasColumn() method calls.
|
is defining a class which extends Doctrine_Record and setting a setTableDefinition method with hasColumn() method calls.
|
||||||
<br \><br \>
|
<br \><br \>
|
||||||
Consider we want to create a database table called 'user' with columns id(primary key), name, username, password and created. You only need couple of lines of code
|
Consider we want to create a database table called 'user' with columns id(primary key), name, username, password and created. You only need couple of lines of code
|
||||||
to create a simple CRUD (Create, Retrieve, Update, Delete) application for this database table.
|
to create a simple up-and-running model.
|
||||||
|
|
||||||
|
@ -88,7 +88,14 @@ $menu = array("Getting started" =>
|
|||||||
"Introduction",
|
"Introduction",
|
||||||
"Data types and lengths",
|
"Data types and lengths",
|
||||||
"Constraints and validators",
|
"Constraints and validators",
|
||||||
|
"Enum emulation"
|
||||||
),
|
),
|
||||||
|
"Record identifiers" => array(
|
||||||
|
"Introduction",
|
||||||
|
"Autoincremented",
|
||||||
|
"Natural",
|
||||||
|
"Composite",
|
||||||
|
"Sequential")
|
||||||
),
|
),
|
||||||
"Basic Components" =>
|
"Basic Components" =>
|
||||||
array(
|
array(
|
||||||
|
@ -472,7 +472,7 @@ class PHP_Highlight
|
|||||||
|
|
||||||
case T_COMMENT:
|
case T_COMMENT:
|
||||||
case T_DOC_COMMENT:
|
case T_DOC_COMMENT:
|
||||||
case T_ML_COMMENT:
|
//case T_ML_COMMENT:
|
||||||
return $this->highlight['comment'];
|
return $this->highlight['comment'];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
<table width="100%" cellspacing=0 cellpadding=0>
|
<table width="100%" cellspacing=0 cellpadding=0>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<a href="index.php">main</a> | <a href="documentation.php">documentation</a> | <a href="https://sourceforge.net/project/showfiles.php?group_id=160015">download</a> | <a href="faq.php">FAQ</a> | <a href="about.php">about</a> | <a href="http://www.phpbbserver.com/phpdoctrine/">forums</a>
|
<?php
|
||||||
|
// https://sourceforge.net/project/showfiles.php?group_id=160015
|
||||||
|
?>
|
||||||
|
<a href="index.php">main</a> | <a href="documentation.php">documentation</a> | <a href="download.php">download</a> | <a href="faq.php">FAQ</a> | <a href="about.php">about</a> | <a href="http://www.phpbbserver.com/phpdoctrine/">forums</a>
|
||||||
</td>
|
</td>
|
||||||
<td width=30>
|
<td width=30>
|
||||||
</td>
|
</td>
|
||||||
|
@ -61,10 +61,10 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
|
|||||||
|
|
||||||
$query->addComponent("entity", "Entity");
|
$query->addComponent("entity", "Entity");
|
||||||
$query->addComponent("phonenumber", "Entity.Phonenumber");
|
$query->addComponent("phonenumber", "Entity.Phonenumber");
|
||||||
|
|
||||||
$coll = $query->execute();
|
$coll = $query->execute();
|
||||||
$this->assertEqual($coll->count(), 11);
|
$this->assertEqual($coll->count(), 11);
|
||||||
|
|
||||||
$count = $this->dbh->count();
|
$count = $this->dbh->count();
|
||||||
|
|
||||||
$coll[4]->Phonenumber[0]->phonenumber;
|
$coll[4]->Phonenumber[0]->phonenumber;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user