samples/PhotoAlbum/lib/rb.php
public function trash( $bean ) {
		if ($bean instanceof RedBean_SimpleModel) $bean = $bean->unbox();
		if (!($bean instanceof RedBean_OODBBean)) throw new RedBean_Exception_Security('OODB Store requires a bean, got: '.gettype($bean));
		$this->signal('delete',$bean);
		foreach($bean as $p=>$v) {
			if ($v instanceof RedBean_OODBBean) {
				$bean->removeProperty($p);
			}
			if (is_array($v)) {
				if (strpos($p,'own')===0) {
					$bean->removeProperty($p);
				}
				elseif (strpos($p,'shared')===0) {
					$bean->removeProperty($p);
				}
			}
		}
		if (!$this->isFrozen) $this->check( $bean );
		try {
			$this->writer->selectRecord($bean->getMeta('type'),
				array('id' => array( $bean->id) ),null,true );
		}catch(RedBean_Exception_SQL $e) {
			if (!$this->writer->sqlStateIn($e->getSQLState(),
			array(
			RedBean_QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN,
			RedBean_QueryWriter::C_SQLSTATE_NO_SUCH_TABLE)
			)) throw $e;
		}
		$bean->id = 0;
		$this->signal('after_delete', $bean );
	}
public function trash( $bean ) {
		if ($bean instanceof RedBean_SimpleModel) $bean = $bean->unbox();
		if (!($bean instanceof RedBean_OODBBean)) throw new RedBean_Exception_Security('OODB Store requires a bean, got: '.gettype($bean));
		$this->signal('delete',$bean);
		foreach($bean as $p=>$v) {
			if ($v instanceof RedBean_OODBBean) {
				$bean->removeProperty($p);
			}
			if (is_array($v)) {
				if (strpos($p,'own')===0) {
					$bean->removeProperty($p);
				}
				elseif (strpos($p,'shared')===0) {
					$bean->removeProperty($p);
				}
			}
		}
		if (!$this->isFrozen) $this->check( $bean );
		try {
			$this->writer->selectRecord($bean->getMeta('type'),
				array('id' => array( $bean->id) ),null,true );
		}catch(RedBean_Exception_SQL $e) {
			if (!$this->writer->sqlStateIn($e->getSQLState(),
			array(
			RedBean_QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN,
			RedBean_QueryWriter::C_SQLSTATE_NO_SUCH_TABLE)
			)) throw $e;
		}
		$bean->id = 0;
		$this->signal('after_delete', $bean );
	}
public function trash ( $ bean ) { if ( $ bean instanceof RedBean_SimpleModel ) $ bean = $ bean -> unbox ( ) ; if ( ! ( $ bean instanceof RedBean_OODBBean ) ) throw new RedBean_Exception_Security ( 'OODB Store requires a bean, got: ' . gettype ( $ bean ) ) ; $ this -> signal ( 'delete' , $ bean ) ; foreach ( $ bean as $ p => $ v ) { if ( $ v instanceof RedBean_OODBBean ) { $ bean -> removeProperty ( $ p ) ; } if ( is_array ( $ v ) ) { if ( strpos ( $ p , 'own' ) === 0 ) { $ bean -> removeProperty ( $ p ) ; } elseif ( strpos ( $ p , 'shared' ) === 0 ) { $ bean -> removeProperty ( $ p ) ; } } } if ( ! $ this -> isFrozen ) $ this -> check ( $ bean ) ; try { $ this -> writer -> selectRecord ( $ bean -> getMeta ( 'type' ) , array ( 'id' => array ( $ bean -> id ) ) , null , true ) ; } catch ( RedBean_Exception_SQL $ e ) { if ( ! $ this -> writer -> sqlStateIn ( $ e -> getSQLState ( ) , array ( RedBean_QueryWriter :: C_SQLSTATE_NO_SUCH_COLUMN , RedBean_QueryWriter :: C_SQLSTATE_NO_SUCH_TABLE ) ) ) throw $ e ; } $ bean -> id = 0 ; $ this -> signal ( 'after_delete' , $ bean ) ; }
Removes a bean from the database.
This function will remove the specified RedBean_OODBBean
Bean Object from the database.

@throws RedBean_Exception_Security $exception

@param RedBean_OODBBean|RedBean_SimpleModel $bean bean you want to remove from database
Removes a bean from the database . This function will remove the specified RedBean_OODBBean Bean Object from the database .