當前位置: 首頁>>代碼示例>>PHP>>正文


PHP xmldb_field::setPrevious方法代碼示例

本文整理匯總了PHP中xmldb_field::setPrevious方法的典型用法代碼示例。如果您正苦於以下問題:PHP xmldb_field::setPrevious方法的具體用法?PHP xmldb_field::setPrevious怎麽用?PHP xmldb_field::setPrevious使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xmldb_field的用法示例。


在下文中一共展示了xmldb_field::setPrevious方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addField

 /**
  * Add one field to the table, allowing to specify the desired  order
  * If it's not specified, then the field is added at the end
  * @param xmldb_field $field
  * @param xmldb_object $after
  * @return xmldb_field
  */
 public function addField($field, $after = null)
 {
     // Detect duplicates first
     if ($this->getField($field->getName())) {
         throw new coding_exception('Duplicate field ' . $field->getName() . ' specified in table ' . $this->getName());
     }
     // Calculate the previous and next fields
     $prevfield = null;
     $nextfield = null;
     if (!$after) {
         $allfields = $this->getFields();
         if (!empty($allfields)) {
             end($allfields);
             $prevfield = $allfields[key($allfields)];
         }
     } else {
         $prevfield = $this->getField($after);
     }
     if ($prevfield && $prevfield->getNext()) {
         $nextfield = $this->getField($prevfield->getNext());
     }
     // Set current field previous and next attributes
     if ($prevfield) {
         $field->setPrevious($prevfield->getName());
         $prevfield->setNext($field->getName());
     }
     if ($nextfield) {
         $field->setNext($nextfield->getName());
         $nextfield->setPrevious($field->getName());
     }
     // Some more attributes
     $field->setLoaded(true);
     $field->setChanged(true);
     // Add the new field
     $this->fields[] = $field;
     // Reorder the field
     $this->orderFields($this->fields);
     // Recalculate the hash
     $this->calculateHash(true);
     // We have one new field, so the table has changed
     $this->setChanged(true);
     return $field;
 }
開發者ID:alanaipe2015,項目名稱:moodle,代碼行數:50,代碼來源:xmldb_table.php

示例2: xmldb_hotpot_fix_previous_field

/**
 * xmldb_hotpot_fix_previous_field
 *
 * @param xxx $dbman
 * @param xmldb_table $table
 * @param xmldb_field $field (passed by reference)
 * @return void, but may update $field->previous
 */
function xmldb_hotpot_fix_previous_field($dbman, $table, &$field)
{
    $previous = $field->getPrevious();
    if (empty($previous) || $dbman->field_exists($table, $previous)) {
        // $previous field exists - do nothing
    } else {
        // $previous field does not exist, so remove it
        $field->setPrevious(null);
    }
}
開發者ID:hapaxapah,項目名稱:moodle-mod_hotpot,代碼行數:18,代碼來源:upgrade.php


注:本文中的xmldb_field::setPrevious方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。