當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。