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


PHP xmldb_field::validateDefinition方法代碼示例

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


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

示例1: getFieldSQL

 /**
  * Given one correct xmldb_field, returns the complete SQL line to create it.
  *
  * @param xmldb_table $xmldb_table The table related to $xmldb_field.
  * @param xmldb_field $xmldb_field The instance of xmldb_field to create the SQL from.
  * @param string $skip_type_clause The type clause on alter columns, NULL by default.
  * @param string $skip_default_clause The default clause on alter columns, NULL by default.
  * @param string $skip_notnull_clause The null/notnull clause on alter columns, NULL by default.
  * @param string $specify_nulls_clause To force a specific null clause, NULL by default.
  * @param bool $specify_field_name Flag to specify fieldname in return.
  * @return string The field generating SQL statement.
  * @throws coding_exception Thrown when xmldb_field doesn't validate with the xmldb_table.
  */
 public function getFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause = NULL, $skip_default_clause = NULL, $skip_notnull_clause = NULL, $specify_nulls_clause = NULL, $specify_field_name = true)
 {
     if ($error = $xmldb_field->validateDefinition($xmldb_table)) {
         throw new coding_exception($error);
     }
     $skip_type_clause = is_null($skip_type_clause) ? $this->alter_column_skip_type : $skip_type_clause;
     $skip_default_clause = is_null($skip_default_clause) ? $this->alter_column_skip_default : $skip_default_clause;
     $skip_notnull_clause = is_null($skip_notnull_clause) ? $this->alter_column_skip_notnull : $skip_notnull_clause;
     $specify_nulls_clause = is_null($specify_nulls_clause) ? $this->specify_nulls : $specify_nulls_clause;
     /// First of all, convert integers to numbers if defined
     if ($this->integer_to_number) {
         if ($xmldb_field->getType() == XMLDB_TYPE_INTEGER) {
             $xmldb_field->setType(XMLDB_TYPE_NUMBER);
         }
     }
     /// Same for floats
     if ($this->float_to_number) {
         if ($xmldb_field->getType() == XMLDB_TYPE_FLOAT) {
             $xmldb_field->setType(XMLDB_TYPE_NUMBER);
         }
     }
     $field = '';
     // Let's accumulate the whole expression based on params and settings
     /// The name
     if ($specify_field_name) {
         $field .= $this->getEncQuoted($xmldb_field->getName());
     }
     /// The type and length only if we don't want to skip it
     if (!$skip_type_clause) {
         /// The type and length
         $field .= ' ' . $this->getTypeSQL($xmldb_field->getType(), $xmldb_field->getLength(), $xmldb_field->getDecimals());
     }
     /// The unsigned if supported
     if ($this->unsigned_allowed && ($xmldb_field->getType() == XMLDB_TYPE_INTEGER || $xmldb_field->getType() == XMLDB_TYPE_NUMBER || $xmldb_field->getType() == XMLDB_TYPE_FLOAT)) {
         if ($xmldb_field->getUnsigned()) {
             $field .= ' unsigned';
         }
     }
     /// Calculate the not null clause
     $notnull = '';
     /// Only if we don't want to skip it
     if (!$skip_notnull_clause) {
         if ($xmldb_field->getNotNull()) {
             $notnull = ' NOT NULL';
         } else {
             if ($specify_nulls_clause) {
                 $notnull = ' NULL';
             }
         }
     }
     /// Calculate the default clause
     $default_clause = '';
     if (!$skip_default_clause) {
         //Only if we don't want to skip it
         $default_clause = $this->getDefaultClause($xmldb_field);
     }
     /// Based on default_after_null, set both clauses properly
     if ($this->default_after_null) {
         $field .= $notnull . $default_clause;
     } else {
         $field .= $default_clause . $notnull;
     }
     /// The sequence
     if ($xmldb_field->getSequence()) {
         if ($xmldb_field->getLength() <= 9 && $this->sequence_name_small) {
             $sequencename = $this->sequence_name_small;
         } else {
             $sequencename = $this->sequence_name;
         }
         $field .= ' ' . $sequencename;
         if ($this->sequence_only) {
             /// We only want the field name and sequence name to be printed
             /// so, calculate it and return
             $sql = $this->getEncQuoted($xmldb_field->getName()) . ' ' . $sequencename;
             return $sql;
         }
     }
     return $field;
 }
開發者ID:,項目名稱:,代碼行數:92,代碼來源:


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