data() public method

Access the data fields of the record. Can also access a $named field.
public data ( string $name = null ) : mixed
$name string Optionally included field name.
return mixed Entire data array if $name is empty, otherwise the value from the named field.
Example #1
0
 public function testConversion()
 {
     $data = array('foo' => '!!', 'bar' => '??', 'baz' => '--');
     $entity = new Entity(compact('data'));
     $this->assertEqual($data, $entity->to('array'));
     $this->assertEqual($data, $entity->data());
     $this->assertEqual($entity, $entity->to('foo'));
 }
Example #2
0
	/**
	 * deleteFromTree
	 * 
	 * deletes a node (and its children) from the tree
	 * 
	 * @param \lithium\data\Model $self the model using this behavior
	 * @param \lithium\data\Entity $entity updated tree element
	 */
	private static function deleteFromTree($self,$entity){
		extract(static::$_tree_config[$self]);
		$span = 1;
		if($entity->data($right) - $entity->data($left) != 1){
			$span = $entity->data($right) - $entity->data($left);
			$connection = $self::connection();
			$connection->read('delete from '.$self::meta('source').' where '.$parent.'='.$entity->data($self::meta('key')),array('return'=>'resource'));
		}
		static::updateNodesIndices($self,$entity->data($right),'-',$span+1);
	}