Ejemplo n.º 1
0
	/**
	* If table key (id) is NULL : inserts a new row
	* otherwise updates existing row in the database table
	*
	* Can be overridden or overloaded by the child class
	*
	* @param  boolean  $updateNulls  TRUE: null object variables are also updated, FALSE: not.
	* @return boolean                TRUE if successful otherwise FALSE
	*/
	function store( $updateNulls = false ) {
		$k					=	$this->_tbl_key;
		if ( $this->$k != null ) {
			$ok				=	$this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
		} else {
			$ok				=	$this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
		}

		if ( ! $ok ) {
			$this->_error	=	strtolower(get_class($this))."::store failed: " . $this->_db->getErrorMsg();
		}
		return $ok;
	}