lithium\data\Entity::schema PHP Method

schema() public method

public schema ( $field = null )
    public function schema($field = null)
    {
        $schema = null;
        switch (true) {
            case is_object($this->_schema):
                $schema = $this->_schema;
                break;
            case $model = $this->_model:
                $schema = $model::schema();
                break;
        }
        if ($schema) {
            return $field ? $schema->fields($field) : $schema;
        }
        return array();
    }

Usage Example

Example #1
0
 public function testSchemaAccess()
 {
     $fields = array('foo' => array('type' => 'string'));
     $schema = new Schema(compact('fields'));
     $entity = new Entity(compact('schema'));
     $this->assertEqual($schema, $entity->schema());
 }