Apache Zeta Components Manual :: File Source for field.php

Source for file field.php

Documentation is available at field.php

  1. <?php
  2. /**
  3.  *
  4.  * Licensed to the Apache Software Foundation (ASF) under one
  5.  * or more contributor license agreements.  See the NOTICE file
  6.  * distributed with this work for additional information
  7.  * regarding copyright ownership.  The ASF licenses this file
  8.  * to you under the Apache License, Version 2.0 (the
  9.  * "License"); you may not use this file except in compliance
  10.  * with the License.  You may obtain a copy of the License at
  11.  * 
  12.  *   http://www.apache.org/licenses/LICENSE-2.0
  13.  * 
  14.  * Unless required by applicable law or agreed to in writing,
  15.  * software distributed under the License is distributed on an
  16.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17.  * KIND, either express or implied.  See the License for the
  18.  * specific language governing permissions and limitations
  19.  * under the License.
  20.  *
  21.  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  22.  * @version //autogentag//
  23.  * @filesource
  24.  * @package DatabaseSchema
  25.  */
  26. /**
  27.  * A container to store a field definition in.
  28.  *
  29.  * @package DatabaseSchema
  30.  * @version //autogentag//
  31.  */
  32. {
  33.     /**
  34.      * The type of this field
  35.      *
  36.      * @var string 
  37.      */
  38.     public $type;
  39.  
  40.     /**
  41.      * The length of this field.
  42.      *
  43.      * @var integer 
  44.      */
  45.     public $length;
  46.  
  47.     /**
  48.      * Whether this field can store NULL values.
  49.      *
  50.      * @var bool 
  51.      */
  52.     public $notNull;
  53.  
  54.     /**
  55.      * The default value for this field.
  56.      *
  57.      * @var mixed 
  58.      */
  59.     public $default;
  60.  
  61.     /**
  62.      * Whether this field is an auto increment field.
  63.      *
  64.      * @var bool 
  65.      */
  66.     public $autoIncrement;
  67.  
  68.     /**
  69.      * Whether the values for this field contain unsigned integers.
  70.      *
  71.      * @var bool 
  72.      */
  73.     public $unsigned;
  74.  
  75.     /**
  76.      * Constructs an ezcDbSchemaField object.
  77.      *
  78.      * @param string  $type 
  79.      * @param integer $length 
  80.      * @param bool    $notNull 
  81.      * @param mixed   $default 
  82.      * @param bool    $autoIncrement 
  83.      * @param bool    $unsigned 
  84.      */
  85.     function __construct$type$length false$notNull false$default null$autoIncrement false$unsigned false )
  86.     {
  87.         $this->type = (string) $type;
  88.         $this->length = (int) $length;
  89.         $this->notNull = (bool) $notNull;
  90.         $this->default = $default;
  91.         $this->autoIncrement = (bool) $autoIncrement;
  92.         $this->unsigned = (bool) $unsigned;
  93.  
  94.         if $type == 'integer' && $notNull && $default === null && $autoIncrement == false )
  95.         {
  96.             $this->default = 0;
  97.         }
  98.  
  99.         if $type == 'integer' && is_numeric$this->default ) )
  100.         {
  101.             $this->default = (int) $this->default;
  102.         }
  103.     }
  104.  
  105.     static public function __set_statearray $array )
  106.     {
  107.         return new ezcDbSchemaField(
  108.             $array['type']$array['length']$array['notNull'],
  109.             $array['default']$array['autoIncrement']$array['unsigned']
  110.         );
  111.     }
  112. }
  113. ?>
Documentation generated by phpDocumentor 1.4.3