small refactorings
This commit is contained in:
parent
be5aac16fd
commit
e354e527d5
@ -480,25 +480,24 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
}
|
||||
|
||||
/**
|
||||
* addMappedColumn
|
||||
* Maps a column of the class' database table to a property of the entity.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @param integer $length
|
||||
* @param string $name The name of the column to map. Syntax: columnName [as propertyName].
|
||||
* The property name is optional. If not used the column will be
|
||||
* mapped to a property with the same name.
|
||||
* @param string $type The type of the column.
|
||||
* @param integer $length The length of the column.
|
||||
* @param mixed $options
|
||||
* @param boolean $prepend Whether to prepend or append the new column to the column list.
|
||||
* By default the column gets appended.
|
||||
*
|
||||
* @throws Doctrine_ClassMetadata_Exception If trying use wrongly typed parameter.
|
||||
*/
|
||||
public function mapColumn($name, $type, $length = null, $options = array(), $prepend = false)
|
||||
{
|
||||
if (is_string($options)) {
|
||||
$options = explode('|', $options);
|
||||
}
|
||||
|
||||
foreach ($options as $k => $option) {
|
||||
if (is_numeric($k)) {
|
||||
if ( ! empty($option)) {
|
||||
if ( ! empty($option) && $option !== false) {
|
||||
$options[$option] = true;
|
||||
}
|
||||
unset($options[$k]);
|
||||
@ -598,7 +597,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
|
||||
/**
|
||||
* hasDefaultValues
|
||||
* returns true if this table has default values, otherwise false
|
||||
* returns true if this class has default values, otherwise false
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@ -609,7 +608,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
|
||||
/**
|
||||
* getDefaultValueOf
|
||||
* returns the default value(if any) for given column
|
||||
* returns the default value(if any) for given field
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return mixed
|
||||
|
@ -20,8 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Doctrine
|
||||
* the base class of Doctrine framework
|
||||
* Testcase for basic accessor/mutator functionality.
|
||||
*
|
||||
* @package Doctrine
|
||||
* @author Bjarte Stien Karlsen <doctrine@bjartek.org>
|
||||
@ -32,6 +31,8 @@
|
||||
*/
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
class AccessStub extends Doctrine_Access {}
|
||||
|
||||
class Orm_Component_AccessTest extends Doctrine_OrmTestCase
|
||||
{
|
||||
|
||||
@ -139,7 +140,6 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
|
||||
$col = new Doctrine_Collection('ForumUser');
|
||||
$this->assertEquals(0, count($col));
|
||||
$this->assertFalse(isset($coll[0]));
|
||||
$this->assertFalse(isset($coll[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,5 +218,3 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
|
||||
$stub['foo'];
|
||||
}
|
||||
}
|
||||
|
||||
class AccessStub extends Doctrine_Access {}
|
||||
|
@ -98,7 +98,7 @@ class Orm_Component_CollectionTest extends Doctrine_OrmTestCase
|
||||
{
|
||||
$serializedFormCollection='C:19:"Doctrine_Collection":158:{a:7:{s:4:"data";a:0:{}s:7:"_mapper";s:9:"ForumUser";s:9:"_snapshot";a:0:{}s:14:"referenceField";N;s:9:"keyColumn";N;s:8:"_locator";N;s:10:"_resources";a:0:{}}}';
|
||||
$coll = unserialize($serializedFormCollection);
|
||||
$this->assertEquals(Doctrine_Collection, get_class($coll));
|
||||
$this->assertEquals('Doctrine_Collection', get_class($coll));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
class CustomPK extends Doctrine_Record {
|
||||
public static function initMetadata($class) {
|
||||
$class->setColumn('uid', 'integer',11, 'autoincrement|primary');
|
||||
$class->setColumn('uid', 'integer',11, array('autoincrement' => true, 'primary' => true));
|
||||
$class->setColumn('name', 'string',255);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ class Email extends Doctrine_Record
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
$class->setColumn('address', 'string', 150, 'email|unique');
|
||||
$class->setColumn('address', 'string', 150, array('email', 'unique' => true));
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,8 +3,8 @@ class EntityReference extends Doctrine_Record
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
$class->setColumn('entity1', 'integer', null, 'primary');
|
||||
$class->setColumn('entity2', 'integer', null, 'primary');
|
||||
$class->setColumn('entity1', 'integer', null, array('primary' => true));
|
||||
$class->setColumn('entity2', 'integer', null, array('primary' => true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ class Error extends Doctrine_Record {
|
||||
public static function initMetadata($class) {
|
||||
$class->setColumn('message', 'string',200);
|
||||
$class->setColumn('code', 'integer',11);
|
||||
$class->setColumn('file_md5', 'string',32, 'primary');
|
||||
$class->setColumn('file_md5', 'string',32, array('primary' => true));
|
||||
$class->hasMany('Description', array('local' => 'file_md5', 'foreign' => 'file_md5'));
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ class MysqlTestRecord extends Doctrine_Record
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
$class->setColumn('name', 'string', null, 'primary');
|
||||
$class->setColumn('code', 'integer', null, 'primary');
|
||||
$class->setColumn('name', 'string', null, array('primary' => true));
|
||||
$class->setColumn('code', 'integer', null, array('primary' => true));
|
||||
|
||||
$class->setTableOption('type', 'INNODB');
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ class NestReference extends Doctrine_Record
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
$class->setColumn('parent_id', 'integer', 4, 'primary');
|
||||
$class->setColumn('child_id', 'integer', 4, 'primary');
|
||||
$class->setColumn('parent_id', 'integer', 4, array('primary' => true));
|
||||
$class->setColumn('child_id', 'integer', 4, array('primary' => true));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
class NotNullTest extends Doctrine_Record {
|
||||
public static function initMetadata($class) {
|
||||
$class->setColumn('name', 'string', 100, 'notnull');
|
||||
$class->setColumn('name', 'string', 100, array('notnull' => true));
|
||||
$class->setColumn('type', 'integer', 11);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user