当前位置: 首页>>代码示例>>PHP>>正文


PHP DB::requireField方法代码示例

本文整理汇总了PHP中DB::requireField方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::requireField方法的具体用法?PHP DB::requireField怎么用?PHP DB::requireField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


在下文中一共展示了DB::requireField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: requireField

 /**
  * Add the field to the underlying database.
  * 
  * @see DBField::requireField()
  */
 public function requireField()
 {
     //@todo change this to use Link rather than basic varchar
     $parts = array('datatype' => 'varchar', 'precision' => 50, 'character set' => 'utf8', 'default' => 0, 'arrayValue' => $this->arrayValue);
     $values = array('type' => 'varchar', 'parts' => $parts);
     DB::requireField($this->tableName, $this->name, $values);
 }
开发者ID:Cumquat,项目名称:silverstripe-orientdb-poc,代码行数:12,代码来源:OrientForeignKey.php

示例2: requireField

 public function requireField()
 {
     $fields = $this->compositeDatabaseFields();
     if ($fields) {
         foreach ($fields as $name => $type) {
             \DB::requireField($this->tableName, $this->name . $name, $type);
         }
     }
 }
开发者ID:spekulatius,项目名称:ss-focus-area,代码行数:9,代码来源:DBField.php

示例3: requireField

 public function requireField()
 {
     // HACK: MSSQL does not support double so we're usinf float instead
     // @todo This should go into MSSQLDatabase ideally somehow
     if (DB::getConn() instanceof MySQLDatabase) {
         DB::requireField($this->tableName, $this->name, "double");
     } else {
         DB::requireField($this->tableName, $this->name, "float");
     }
 }
开发者ID:normann,项目名称:sapphire,代码行数:10,代码来源:Double.php

示例4: requireField

 /**
  * (non-PHPdoc)
  * @see DBField::requireField()
  */
 public function requireField()
 {
     $parts = array('datatype' => 'varchar', 'precision' => 9, 'character set' => 'utf8', 'collate' => 'utf8_general_ci', 'arrayValue' => $this->arrayValue);
     $values = array('type' => 'varchar', 'parts' => $parts);
     // Add support for both SS DB API 3.2 and <3.2
     if (method_exists('DB', 'require_field')) {
         DB::require_field($this->tableName, $this->name, $values);
     } else {
         DB::requireField($this->tableName, $this->name, $values);
     }
 }
开发者ID:helpfulrobot,项目名称:colymba-silverstripe-colorfield,代码行数:15,代码来源:Color.php

示例5: requireField

 	/**
 	 * (non-PHPdoc)
 	 * @see DBField::requireField()
 	 */
	function requireField() {
		$parts = array(
			'datatype'=>'varchar',
			'precision'=>$this->size,
			'character set'=>'utf8',
			'collate'=>'utf8_general_ci',
			'arrayValue'=>$this->arrayValue
		);
		
		$values = array(
			'type' => 'varchar',
			'parts' => $parts
		);
			
		DB::requireField($this->tableName, $this->name, $values);
	}
开发者ID:redema,项目名称:sapphire,代码行数:20,代码来源:Varchar.php

示例6: requireField

 /**
  * Compose the requirements for this field
  *
  * Note: Issue with this approach is if the same name is used in different relations,
  * believe this is a limitation with SilverStripe anyway.
  * many_many = array('Name' => 'SomeClass')
  * belongs_many_many = array('Name' => 'SomeOtherClass')
  * 
  * @return void
  */
 public function requireField()
 {
     //Get the type of object for this relation and pass to OrientDatabase::linkset() effectively
     //@todo @has_many same treatment for has_many
     //@todo @belongs_many_many same treatment for belongs_many_many
     $relationClass = null;
     //Does the tableName always match the class name?
     $manyMany = Config::inst()->get($this->tableName, 'many_many', Config::UNINHERITED);
     if (isset($manyMany[$this->name])) {
         $relationClass = $manyMany[$this->name];
     }
     $belongsManyMany = Config::inst()->get($this->tableName, 'belongs_many_many', Config::UNINHERITED);
     if (isset($belongsManyMany[$this->name])) {
         $relationClass = $belongsManyMany[$this->name];
     }
     //If the relation class cannot be found do not create the linkset at all
     if (!$relationClass) {
         return;
     }
     $parts = array('datatype' => 'linkset', 'precision' => null, 'null' => null, 'default' => null, 'arrayValue' => null, 'relationClass' => $relationClass);
     $values = array('type' => 'linkset', 'parts' => $parts);
     DB::requireField($this->tableName, $this->name, $values);
 }
开发者ID:Cumquat,项目名称:silverstripe-orientdb-poc,代码行数:33,代码来源:OrientLinkSet.php

示例7: augmentDatabase

 function augmentDatabase()
 {
     $classTable = $this->owner->class;
     // Build a list of suffixes whose tables need versioning
     $allSuffixes = array();
     foreach (Versioned::$versionableExtensions as $versionableExtension => $suffixes) {
         if ($this->owner->hasExtension($versionableExtension) && singleton($versionableExtension)->stat('enabled')) {
             $allSuffixes = array_merge($allSuffixes, (array) $suffixes);
             foreach ((array) $suffixes as $suffix) {
                 $allSuffixes[$suffix] = $versionableExtension;
             }
         }
     }
     // Add the default table with an empty suffix to the list (table name = class name)
     array_push($allSuffixes, '');
     foreach ($allSuffixes as $key => $suffix) {
         // check that this is a valid suffix
         if (!is_int($key)) {
             continue;
         }
         if ($suffix) {
             $table = "{$classTable}_{$suffix}";
         } else {
             $table = $classTable;
         }
         if ($fields = $this->owner->databaseFields()) {
             $indexes = $this->owner->databaseIndexes();
             if ($this->owner->parentClass() == "DataObject") {
                 $rootTable = true;
             }
             if ($suffix && ($ext = $this->owner->extInstance($allSuffixes[$suffix]))) {
                 if (!$ext->isVersionedTable($table)) {
                     continue;
                 }
                 $fields = $ext->fieldsInExtraTables($suffix);
                 $indexes = $fields['indexes'];
                 $fields = $fields['db'];
             }
             // Create tables for other stages
             foreach ($this->stages as $stage) {
                 // Extra tables for _Live, etc.
                 if ($stage != $this->defaultStage) {
                     DB::requireTable("{$table}_{$stage}", $fields, $indexes);
                     /*
                     if(!DB::query("SELECT * FROM {$table}_$stage")->value()) {
                     	$fieldList = implode(", ",array_keys($fields));
                     	DB::query("INSERT INTO `{$table}_$stage` (ID,$fieldList)
                     		SELECT ID,$fieldList FROM `$table`");
                     }
                     */
                 }
                 // Version fields on each root table (including Stage)
                 if (isset($rootTable)) {
                     $stageTable = $stage == $this->defaultStage ? $table : "{$table}_{$stage}";
                     DB::requireField($stageTable, "Version", "int(11) not null default '0'");
                 }
             }
             // Create table for all versions
             $versionFields = array_merge(array("RecordID" => "Int", "Version" => "Int", "WasPublished" => "Boolean", "AuthorID" => "Int", "PublisherID" => "Int"), (array) $fields);
             $versionIndexes = array_merge(array('RecordID_Version' => '(RecordID, Version)', 'RecordID' => true, 'Version' => true, 'AuthorID' => true, 'PublisherID' => true), (array) $indexes);
             DB::requireTable("{$table}_versions", $versionFields, $versionIndexes);
             /*
             if(!DB::query("SELECT * FROM {$table}_versions")->value()) {
             	$fieldList = implode(", ",array_keys($fields));
             					
             	DB::query("INSERT INTO `{$table}_versions` ($fieldList, RecordID, Version) 
             		SELECT $fieldList, ID AS RecordID, 1 AS Version FROM `$table`");
             }
             */
         } else {
             DB::dontRequireTable("{$table}_versions");
             foreach ($this->stages as $stage) {
                 if ($stage != $this->defaultStage) {
                     DB::dontrequireTable("{$table}_{$stage}");
                 }
             }
         }
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:79,代码来源:Versioned.php

示例8: requireField

 function requireField()
 {
     DB::requireField($this->tableName, $this->name, "float");
 }
开发者ID:ramziammar,项目名称:websites,代码行数:4,代码来源:Float.php

示例9: requireField

 public function requireField()
 {
     $parts = array('datatype' => 'longblob', 'arrayValue' => $this->arrayValue);
     $values = array('type' => 'longblob', 'parts' => $parts);
     DB::requireField($this->tableName, $this->name, $values, $this->default);
 }
开发者ID:bueckl,项目名称:postmarkedapp,代码行数:6,代码来源:BLOBField.php

示例10: requireField

	function requireField() {
		DB::requireField($this->tableName, $this->name, "tinyint(1) unsigned not null default '{$this->defaultVal}'");
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:3,代码来源:Boolean.php

示例11: requireField

 public function requireField()
 {
     $parts = array('datatype' => 'year', 'precision' => 4, 'arrayValue' => $this->arrayValue);
     $values = array('type' => 'year', 'parts' => $parts);
     DB::requireField($this->tableName, $this->name, $values);
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:6,代码来源:Year.php

示例12: requireField

 /**
  * Add the field to the underlying database.
  */
 public function requireField()
 {
     DB::requireField($this->tableName, $this->name, 'mediumblob');
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-checkfront,代码行数:7,代码来源:Slip.php

示例13: augmentDatabase

 function augmentDatabase()
 {
     $classTable = $this->owner->class;
     $isRootClass = $this->owner->class == ClassInfo::baseDataClass($this->owner->class);
     // Build a list of suffixes whose tables need versioning
     $allSuffixes = array();
     foreach (Versioned::$versionableExtensions as $versionableExtension => $suffixes) {
         if ($this->owner->hasExtension($versionableExtension) && singleton($versionableExtension)->stat('enabled')) {
             $allSuffixes = array_merge($allSuffixes, (array) $suffixes);
             foreach ((array) $suffixes as $suffix) {
                 $allSuffixes[$suffix] = $versionableExtension;
             }
         }
     }
     // Add the default table with an empty suffix to the list (table name = class name)
     array_push($allSuffixes, '');
     foreach ($allSuffixes as $key => $suffix) {
         // check that this is a valid suffix
         if (!is_int($key)) {
             continue;
         }
         if ($suffix) {
             $table = "{$classTable}_{$suffix}";
         } else {
             $table = $classTable;
         }
         if ($fields = $this->owner->databaseFields()) {
             $indexes = $this->owner->databaseIndexes();
             if ($suffix && ($ext = $this->owner->extInstance($allSuffixes[$suffix]))) {
                 if (!$ext->isVersionedTable($table)) {
                     continue;
                 }
                 $fields = $ext->fieldsInExtraTables($suffix);
                 $indexes = $fields['indexes'];
                 $fields = $fields['db'];
             }
             // Create tables for other stages
             foreach ($this->stages as $stage) {
                 // Extra tables for _Live, etc.
                 if ($stage != $this->defaultStage) {
                     DB::requireTable("{$table}_{$stage}", $fields, $indexes);
                 }
                 // Version fields on each root table (including Stage)
                 if ($isRootClass) {
                     $stageTable = $stage == $this->defaultStage ? $table : "{$table}_{$stage}";
                     DB::requireField($stageTable, "Version", "int(11) not null default '0'");
                 }
             }
             if ($isRootClass) {
                 // Create table for all versions
                 $versionFields = array_merge(array("RecordID" => "Int", "Version" => "Int", "WasPublished" => "Boolean", "AuthorID" => "Int", "PublisherID" => "Int"), (array) $fields);
                 $versionIndexes = array_merge(array('RecordID_Version' => '(RecordID, Version)', 'RecordID' => true, 'Version' => true, 'AuthorID' => true, 'PublisherID' => true), (array) $indexes);
             } else {
                 // Create fields for any tables of subclasses
                 $versionFields = array_merge(array("RecordID" => "Int", "Version" => "Int"), (array) $fields);
                 $versionIndexes = array_merge(array('RecordID_Version' => '(RecordID, Version)', 'RecordID' => true, 'Version' => true), (array) $indexes);
             }
             DB::requireTable("{$table}_versions", $versionFields, $versionIndexes);
         } else {
             DB::dontRequireTable("{$table}_versions");
             foreach ($this->stages as $stage) {
                 if ($stage != $this->defaultStage) {
                     DB::dontrequireTable("{$table}_{$stage}");
                 }
             }
         }
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:68,代码来源:Versioned.php

示例14: requireField

 function requireField()
 {
     $parts = array('datatype' => 'date', 'arrayValue' => $this->arrayValue);
     $values = array('type' => 'date', 'parts' => $parts);
     DB::requireField($this->tableName, $this->name, $values);
 }
开发者ID:comperio,项目名称:silverstripe-framework,代码行数:6,代码来源:Date.php

示例15: requireField

 function requireField()
 {
     $values = array('type' => 'set', 'parts' => array('enums' => $this->enum, 'character set' => 'utf8', 'collate' => 'utf8_general_ci', 'default' => Convert::raw2sql($this->default), 'table' => $this->tableName, 'arrayValue' => $this->arrayValue));
     DB::requireField($this->tableName, $this->name, $values);
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:5,代码来源:MultiEnum.php


注:本文中的DB::requireField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。