lithium\data\Schema::type PHP Method

type() public method

public type ( $field )
    public function type($field)
    {
        if (!isset($this->_fields[$field]['type'])) {
            return null;
        }
        $type = $this->_fields[$field]['type'];
        return isset($this->_types[$type]) ? $this->_types[$type] : $type;
    }

Usage Example

Ejemplo n.º 1
0
 public function testShortHandTypeDefinitions()
 {
     $schema = new Schema(array('fields' => array('id' => 'int', 'name' => 'string', 'active' => array('type' => 'boolean', 'default' => true))));
     $this->assertEqual('int', $schema->type('id'));
     $this->assertEqual('string', $schema->type('name'));
     $this->assertEqual('boolean', $schema->type('active'));
     $this->assertEqual(array('type' => 'int'), $schema->fields('id'));
     $this->assertEqual(array('id', 'name', 'active'), $schema->names());
     $expected = array('id' => array('type' => 'int'), 'name' => array('type' => 'string'), 'active' => array('type' => 'boolean', 'default' => true));
     $this->assertEqual($expected, $schema->fields());
 }