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

  • CPgsqlColumnSchema
  • CPgsqlCommandBuilder
  • CPgsqlSchema
  • CPgsqlTableSchema
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * CPgsqlColumnSchema 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:  * CPgsqlColumnSchema class describes the column meta data of a PostgreSQL table.
13:  *
14:  * @author Qiang Xue <qiang.xue@gmail.com>
15:  * @package system.db.schema.pgsql
16:  * @since 1.0
17:  */
18: class CPgsqlColumnSchema 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(strpos($dbType,'[')!==false || strpos($dbType,'char')!==false || strpos($dbType,'text')!==false)
27:             $this->type='string';
28:         elseif(strpos($dbType,'bool')!==false)
29:             $this->type='boolean';
30:         elseif(preg_match('/(real|float|double)/',$dbType))
31:             $this->type='double';
32:         elseif(preg_match('/(integer|oid|serial|smallint)/',$dbType))
33:             $this->type='integer';
34:         else
35:             $this->type='string';
36:     }
37: 
38:     /**
39:      * Extracts size, precision and scale information from column's DB type.
40:      * @param string $dbType the column's DB type
41:      */
42:     protected function extractLimit($dbType)
43:     {
44:         if(strpos($dbType,'('))
45:         {
46:             if (preg_match('/^time.*\((.*)\)/',$dbType,$matches))
47:             {
48:                 $this->precision=(int)$matches[1];
49:             }
50:             elseif (preg_match('/\((.*)\)/',$dbType,$matches))
51:             {
52:                 $values=explode(',',$matches[1]);
53:                 $this->size=$this->precision=(int)$values[0];
54:                 if(isset($values[1]))
55:                     $this->scale=(int)$values[1];
56:             }
57:         }
58:     }
59: 
60:     /**
61:      * Extracts the default value for the column.
62:      * The value is typecasted to correct PHP type.
63:      * @param mixed $defaultValue the default value obtained from metadata
64:      */
65:     protected function extractDefault($defaultValue)
66:     {
67:         if($defaultValue==='true')
68:             $this->defaultValue=true;
69:         elseif($defaultValue==='false')
70:             $this->defaultValue=false;
71:         elseif(strpos($defaultValue,'nextval')===0)
72:             $this->defaultValue=null;
73:         elseif(preg_match('/^\'(.*)\'::/',$defaultValue,$matches))
74:             $this->defaultValue=$this->typecast(str_replace("''","'",$matches[1]));
75:         elseif(preg_match('/^(-?\d+(\.\d*)?)(::.*)?$/',$defaultValue,$matches))
76:             $this->defaultValue=$this->typecast($matches[1]);
77:         // else is null
78:     }
79: }
80: 
API documentation generated by ApiGen 2.8.0