Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CMysqlColumnSchema
  • CMysqlCommandBuilder
  • CMysqlSchema
  • CMysqlTableSchema
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * CMysqlColumnSchema class file.
 4:  *
 5:  * @author Qiang Xue <qiang.xue@gmail.com>
 6:  * @link http://www.yiiframework.com/
 7:  * @copyright 2008-2013 Yii Software LLC
 8:  * @license http://www.yiiframework.com/license/
 9:  */
10: 
11: /**
12:  * CMysqlColumnSchema class describes the column meta data of a MySQL table.
13:  *
14:  * @author Qiang Xue <qiang.xue@gmail.com>
15:  * @package system.db.schema.mysql
16:  * @since 1.0
17:  */
18: class CMysqlColumnSchema extends CDbColumnSchema
19: {
20:     /**
21:      * Extracts the PHP type from DB type.
22:      * @param string $dbType DB type
23:      */
24:     protected function extractType($dbType)
25:     {
26:         if(strncmp($dbType,'enum',4)===0)
27:             $this->type='string';
28:         elseif(strpos($dbType,'float')!==false || strpos($dbType,'double')!==false)
29:             $this->type='double';
30:         elseif(strpos($dbType,'bool')!==false)
31:             $this->type='boolean';
32:         elseif(strpos($dbType,'int')===0 && strpos($dbType,'unsigned')===false || preg_match('/(bit|tinyint|smallint|mediumint)/',$dbType))
33:             $this->type='integer';
34:         else
35:             $this->type='string';
36:     }
37: 
38:     /**
39:      * Extracts the default value for the column.
40:      * The value is typecasted to correct PHP type.
41:      * @param mixed $defaultValue the default value obtained from metadata
42:      */
43:     protected function extractDefault($defaultValue)
44:     {
45:         if(strncmp($this->dbType,'bit',3)===0)
46:             $this->defaultValue=bindec(trim($defaultValue,'b\''));
47:         elseif($this->dbType==='timestamp' && $defaultValue==='CURRENT_TIMESTAMP')
48:             $this->defaultValue=null;
49:         else
50:             parent::extractDefault($defaultValue);
51:     }
52: 
53:     /**
54:      * Extracts size, precision and scale information from column's DB type.
55:      * @param string $dbType the column's DB type
56:      */
57:     protected function extractLimit($dbType)
58:     {
59:         if (strncmp($dbType, 'enum', 4)===0 && preg_match('/\(([\'"])(.*)\\1\)/',$dbType,$matches))
60:         {
61:             // explode by (single or double) quote and comma (ENUM values may contain commas)
62:             $values = explode($matches[1].','.$matches[1], $matches[2]);
63:             $size = 0;
64:             foreach($values as $value)
65:             {
66:                 if(($n=strlen($value)) > $size)
67:                     $size=$n;
68:             }
69:             $this->size = $this->precision = $size;
70:         }
71:         else
72:             parent::extractLimit($dbType);
73:     }
74: }
75: 
API documentation generated by ApiGen 2.8.0