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


PHP Table::generateFieldSpec方法代碼示例

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


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

示例1: PMA_buildColumnCreationStatement

/**
 * Initiate the column creation statement according to the table creation or
 * add columns to a existing table
 *
 * @param int     $field_cnt     number of columns
 * @param boolean $is_create_tbl true if requirement is to get the statement
 *                               for table creation
 *
 * @return array  $definitions An array of initial sql statements
 *                             according to the request
 */
function PMA_buildColumnCreationStatement($field_cnt, $is_create_tbl = true)
{
    $definitions = array();
    for ($i = 0; $i < $field_cnt; ++$i) {
        // '0' is also empty for php :-(
        if (empty($_REQUEST['field_name'][$i]) && $_REQUEST['field_name'][$i] != '0') {
            continue;
        }
        $definition = PMA_getStatementPrefix($is_create_tbl) . Table::generateFieldSpec(trim($_REQUEST['field_name'][$i]), $_REQUEST['field_type'][$i], $_REQUEST['field_length'][$i], $_REQUEST['field_attribute'][$i], isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '', isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : 'NOT NULL', $_REQUEST['field_default_type'][$i], $_REQUEST['field_default_value'][$i], isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false, isset($_REQUEST['field_comments'][$i]) ? $_REQUEST['field_comments'][$i] : '', isset($_REQUEST['field_virtuality'][$i]) ? $_REQUEST['field_virtuality'][$i] : '', isset($_REQUEST['field_expression'][$i]) ? $_REQUEST['field_expression'][$i] : '');
        $definition .= PMA_setColumnCreationStatementSuffix($i, $is_create_tbl);
        $definitions[] = $definition;
    }
    // end for
    return $definitions;
}
開發者ID:rugbyprof,項目名稱:phpmyadmin,代碼行數:26,代碼來源:create_addfield.lib.php

示例2: testGenerateFieldSpec

 /**
  * Test for generateFieldSpec
  *
  * @return void
  */
 public function testGenerateFieldSpec()
 {
     //type is BIT
     $name = "PMA_name";
     $type = "BIT";
     $length = '12';
     $attribute = 'PMA_attribute';
     $collation = 'PMA_collation';
     $null = 'NULL';
     $default_type = 'USER_DEFINED';
     $default_value = 12;
     $extra = 'AUTO_INCREMENT';
     $comment = 'PMA_comment';
     $virtuality = '';
     $expression = '';
     $move_to = '-first';
     $query = Table::generateFieldSpec($name, $type, $length, $attribute, $collation, $null, $default_type, $default_value, $extra, $comment, $virtuality, $expression, $move_to);
     $this->assertEquals("`PMA_name` BIT(12) PMA_attribute NULL DEFAULT b'10' " . "AUTO_INCREMENT COMMENT 'PMA_comment' FIRST", $query);
     //type is DOUBLE
     $type = "DOUBLE";
     $query = Table::generateFieldSpec($name, $type, $length, $attribute, $collation, $null, $default_type, $default_value, $extra, $comment, $virtuality, $expression, $move_to);
     $this->assertEquals("`PMA_name` DOUBLE(12) PMA_attribute NULL DEFAULT '12' " . "AUTO_INCREMENT COMMENT 'PMA_comment' FIRST", $query);
     //type is BOOLEAN
     $type = "BOOLEAN";
     $query = Table::generateFieldSpec($name, $type, $length, $attribute, $collation, $null, $default_type, $default_value, $extra, $comment, $virtuality, $expression, $move_to);
     $this->assertEquals("`PMA_name` BOOLEAN PMA_attribute NULL DEFAULT TRUE " . "AUTO_INCREMENT COMMENT 'PMA_comment' FIRST", $query);
     //$default_type is NULL
     $default_type = 'NULL';
     $query = Table::generateFieldSpec($name, $type, $length, $attribute, $collation, $null, $default_type, $default_value, $extra, $comment, $virtuality, $expression, $move_to);
     $this->assertEquals("`PMA_name` BOOLEAN PMA_attribute NULL DEFAULT NULL " . "AUTO_INCREMENT COMMENT 'PMA_comment' FIRST", $query);
     //$default_type is CURRENT_TIMESTAMP
     $default_type = 'CURRENT_TIMESTAMP';
     $query = Table::generateFieldSpec($name, $type, $length, $attribute, $collation, $null, $default_type, $default_value, $extra, $comment, $virtuality, $expression, $move_to);
     $this->assertEquals("`PMA_name` BOOLEAN PMA_attribute NULL DEFAULT CURRENT_TIMESTAMP " . "AUTO_INCREMENT COMMENT 'PMA_comment' FIRST", $query);
     //$default_type is NONE
     $default_type = 'NONE';
     $extra = 'INCREMENT';
     $move_to = '-first';
     $query = Table::generateFieldSpec($name, $type, $length, $attribute, $collation, $null, $default_type, $default_value, $extra, $comment, $virtuality, $expression, $move_to);
     $this->assertEquals("`PMA_name` BOOLEAN PMA_attribute NULL INCREMENT " . "COMMENT 'PMA_comment' FIRST", $query);
 }
開發者ID:pboutin44,項目名稱:maintest,代碼行數:46,代碼來源:TableTest.php

示例3: generateAlter

 /**
  * Generates column specification for ALTER syntax
  *
  * @param string      $oldcol        old column name
  * @param string      $newcol        new column name
  * @param string      $type          type ('INT', 'VARCHAR', 'BIT', ...)
  * @param string      $length        length ('2', '5,2', '', ...)
  * @param string      $attribute     attribute
  * @param string      $collation     collation
  * @param bool|string $null          with 'NULL' or 'NOT NULL'
  * @param string      $default_type  whether default is CURRENT_TIMESTAMP,
  *                                   NULL, NONE, USER_DEFINED
  * @param string      $default_value default value for USER_DEFINED default
  *                                   type
  * @param string      $extra         'AUTO_INCREMENT'
  * @param string      $comment       field comment
  * @param string      $virtuality    virtuality of the column
  * @param string      $expression    expression for the virtual column
  * @param string      $move_to       new position for column
  *
  * @see Table::generateFieldSpec()
  *
  * @return string  field specification
  */
 public static function generateAlter($oldcol, $newcol, $type, $length, $attribute, $collation, $null, $default_type, $default_value, $extra, $comment, $virtuality, $expression, $move_to)
 {
     return Util::backquote($oldcol) . ' ' . Table::generateFieldSpec($newcol, $type, $length, $attribute, $collation, $null, $default_type, $default_value, $extra, $comment, $virtuality, $expression, $move_to);
 }
開發者ID:ryanfmurphy,項目名稱:phpmyadmin,代碼行數:28,代碼來源:Table.php


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