lithium\data\Schema::fields PHP Method

fields() public method

public fields ( $name = null, $key = null )
    public function fields($name = null, $key = null)
    {
        if (!$name) {
            return $this->_fields;
        }
        $field = isset($this->_fields[$name]) ? $this->_fields[$name] : null;
        if ($field && $key) {
            return isset($field[$key]) ? $field[$key] : null;
        }
        return $field;
    }

Usage Example

Exemplo 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());
 }