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


PHP DboSource::length方法代碼示例

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


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

示例1: testLength

 /**
  * testLength method
  *
  * @return void
  */
 public function testLength()
 {
     $result = $this->Dbo->length('varchar(255)');
     $expected = 255;
     $this->assertSame($expected, $result);
     $result = $this->Dbo->length('int(11)');
     $expected = 11;
     $this->assertSame($expected, $result);
     $result = $this->Dbo->length('float(5,3)');
     $expected = '5,3';
     $this->assertSame($expected, $result);
     $result = $this->Dbo->length('decimal(5,2)');
     $expected = '5,2';
     $this->assertSame($expected, $result);
     $result = $this->Dbo->length("enum('test','me','now')");
     $expected = 4;
     $this->assertSame($expected, $result);
     $result = $this->Dbo->length("set('a','b','cd')");
     $expected = 2;
     $this->assertSame($expected, $result);
     $result = $this->Dbo->length(false);
     $this->assertTrue($result === null);
     $result = $this->Dbo->length('datetime');
     $expected = null;
     $this->assertSame($expected, $result);
     $result = $this->Dbo->length('text');
     $expected = null;
     $this->assertSame($expected, $result);
 }
開發者ID:laiello,項目名稱:double-l-bookmanagement,代碼行數:34,代碼來源:MysqlTest.php

示例2: length

 /**
  * Handle SQLServer specific length properties.
  * SQLServer handles text types as nvarchar/varchar with a length of -1.
  *
  * @param mixed $length Either the length as a string, or a Column descriptor object.
  * @return mixed null|integer with length of column.
  */
 public function length($length)
 {
     if (is_object($length) && isset($length->Length)) {
         $type = strtolower($length->Type);
         if ($length->Size > 0) {
             return $length->Precision . ',' . $length->Size;
         }
         if (strpos($type, 'number') !== false) {
             if (!empty($length->Precision)) {
                 return $length->Precision;
             } else {
                 return '11';
             }
         }
         if (strpos($type, 'date') !== false) {
             return null;
         }
         return $length->Length;
     }
     return parent::length($length);
 }
開發者ID:alphp,項目名稱:cakephp-2.x_oracle-driver,代碼行數:28,代碼來源:Oracle.php

示例3: length

 /**
  * Gets the length of a database-native column description, or null if no length
  *
  * @param string $real Real database-layer column type (i.e. "varchar(255)")
  * @return int An integer representing the length of the column
  */
 public function length($real)
 {
     $col = $real;
     if (strpos($real, '(') !== false) {
         list($col, $limit) = explode('(', $real);
     }
     if ($col === 'uuid') {
         return 36;
     }
     return parent::length($real);
 }
開發者ID:hodrigohamalho,項目名稱:cakephp-ex,代碼行數:17,代碼來源:Postgres.php

示例4: length

 /**
  * Handle SQLServer specific length properties.
  * SQLServer handles text types as nvarchar/varchar with a length of -1.
  *
  * @param mixed $length Either the length as a string, or a Column descriptor object.
  * @return mixed null|integer with length of column.
  */
 public function length($length)
 {
     if (is_object($length) && isset($length->Length)) {
         if ($length->Length == -1 && strpos($length->Type, 'char') !== false) {
             return null;
         }
         if (in_array($length->Type, array('nchar', 'nvarchar'))) {
             return floor($length->Length / 2);
         }
         return $length->Length;
     }
     return parent::length($length);
 }
開發者ID:jrbasso,項目名稱:cakephp,代碼行數:20,代碼來源:Sqlserver.php

示例5: length

 /**
  * Handle SQLServer specific length properties.
  * SQLServer handles text types as nvarchar/varchar with a length of -1.
  *
  * @param mixed $length Either the length as a string, or a Column descriptor object.
  *
  * @return mixed null|integer with length of column.
  */
 public function length($length)
 {
     if (is_object($length) && isset($length->Length)) {
         if ($length->Length == -1 && strpos($length->Type, 'char') !== FALSE) {
             return NULL;
         }
         if (in_array($length->Type, array('nchar', 'nvarchar'))) {
             return floor($length->Length / 2);
         }
         if ($length->Type === 'text') {
             return NULL;
         }
         return $length->Length;
     }
     return parent::length($length);
 }
開發者ID:mrbadao,項目名稱:api-official,代碼行數:24,代碼來源:Sqlserver.php


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