public function saveItem( MShop_Common_Item_Interface $item, $fetch = true )
	{
		$iface = 'MShop_Common_Item_Type_Interface';
		if( !( $item instanceof $iface ) ) {
			throw new MShop_Exception( sprintf( 'Object is not of required type "%1$s"', $iface ) );
		}

		if( $item->isModified() === false ) { return; }

		$dbm = $this->_context->getDatabaseManager();
		$dbname = $this->_getResourceName();
		$conn = $dbm->acquire( $dbname );

		try
		{
			$id = $item->getId();

			if( $id === null ) {
				$sql = $this->_config['insert'];
			} else {
				$sql = $this->_config['update'];
			}

			$statement = $conn->create( $sql );

			$statement->bind( 1, $this->_context->getLocale()->getSiteId(), MW_DB_Statement_Abstract::PARAM_INT );
			$statement->bind( 2, $item->getCode(), MW_DB_Statement_Abstract::PARAM_STR );
			$statement->bind( 3, $item->getDomain(), MW_DB_Statement_Abstract::PARAM_STR );
			$statement->bind( 4, $item->getLabel(), MW_DB_Statement_Abstract::PARAM_STR );
			$statement->bind( 5, $item->getStatus(), MW_DB_Statement_Abstract::PARAM_INT );
			$statement->bind( 6, date('Y-m-d H:i:s', time()));//mtime
			$statement->bind( 7, $this->_context->getEditor());

			if( $id !== null ) {
				$statement->bind( 8, $id, MW_DB_Statement_Abstract::PARAM_INT );
			} else {
				$statement->bind( 8, date('Y-m-d H:i:s', time()));//ctime
			}

			$statement->execute()->finish();

			if( $fetch === true )
			{
				if( $id === null ) {
					$item->setId( $this->_newId( $conn, $this->_config['newid'] ) );
				} else {
					$item->setId( $id ); // modified false
				}
			}

			$dbm->release( $conn, $dbname );
		}
		catch( Exception $e )
		{
			$dbm->release( $conn, $dbname );
			throw $e;
		}
	}
public function saveItem( MShop_Common_Item_Interface $item, $fetch = true )
	{
		$iface = 'MShop_Common_Item_Type_Interface';
		if( !( $item instanceof $iface ) ) {
			throw new MShop_Exception( sprintf( 'Object is not of required type "%1$s"', $iface ) );
		}

		if( $item->isModified() === false ) { return; }

		$dbm = $this->_context->getDatabaseManager();
		$dbname = $this->_getResourceName();
		$conn = $dbm->acquire( $dbname );

		try
		{
			$id = $item->getId();

			if( $id === null ) {
				$sql = $this->_config['insert'];
			} else {
				$sql = $this->_config['update'];
			}

			$statement = $conn->create( $sql );

			$statement->bind( 1, $this->_context->getLocale()->getSiteId(), MW_DB_Statement_Abstract::PARAM_INT );
			$statement->bind( 2, $item->getCode(), MW_DB_Statement_Abstract::PARAM_STR );
			$statement->bind( 3, $item->getDomain(), MW_DB_Statement_Abstract::PARAM_STR );
			$statement->bind( 4, $item->getLabel(), MW_DB_Statement_Abstract::PARAM_STR );
			$statement->bind( 5, $item->getStatus(), MW_DB_Statement_Abstract::PARAM_INT );
			$statement->bind( 6, date('Y-m-d H:i:s', time()));//mtime
			$statement->bind( 7, $this->_context->getEditor());

			if( $id !== null ) {
				$statement->bind( 8, $id, MW_DB_Statement_Abstract::PARAM_INT );
			} else {
				$statement->bind( 8, date('Y-m-d H:i:s', time()));//ctime
			}

			$statement->execute()->finish();

			if( $fetch === true )
			{
				if( $id === null ) {
					$item->setId( $this->_newId( $conn, $this->_config['newid'] ) );
				} else {
					$item->setId( $id ); // modified false
				}
			}

			$dbm->release( $conn, $dbname );
		}
		catch( Exception $e )
		{
			$dbm->release( $conn, $dbname );
			throw $e;
		}
	}
public function saveItem ( MShop_Common_Item_Interface $ item , $ fetch = true ) { $ iface = 'MShop_Common_Item_Type_Interface' ; if ( ! ( $ item instanceof $ iface ) ) { throw new MShop_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ iface ) ) ; } if ( $ item -> isModified ( ) === false ) { return ; } $ dbm = $ this -> _context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ id = $ item -> getId ( ) ; if ( $ id === null ) { $ sql = $ this -> _config [ 'insert' ] ; } else { $ sql = $ this -> _config [ 'update' ] ; } $ statement = $ conn -> create ( $ sql ) ; $ statement -> bind ( 1 , $ this -> _context -> getLocale ( ) -> getSiteId ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ statement -> bind ( 2 , $ item -> getCode ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ statement -> bind ( 3 , $ item -> getDomain ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ statement -> bind ( 4 , $ item -> getLabel ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ statement -> bind ( 5 , $ item -> getStatus ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ statement -> bind ( 6 , date ( 'Y-m-d H:i:s' , time ( ) ) ) ; //mtime $ statement -> bind ( 7 , $ this -> _context -> getEditor ( ) ) ; if ( $ id !== null ) { $ statement -> bind ( 8 , $ id , MW_DB_Statement_Abstract :: PARAM_INT ) ; } else { $ statement -> bind ( 8 , date ( 'Y-m-d H:i:s' , time ( ) ) ) ; //ctime } $ statement -> execute ( ) -> finish ( ) ; if ( $ fetch === true ) { if ( $ id === null ) { $ item -> setId ( $ this -> _newId ( $ conn , $ this -> _config [ 'newid' ] ) ) ; } else { $ item -> setId ( $ id ) ; // modified false } } $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } }
Adds or updates a type item object.

@param MShop_Common_Item_Type_Interface $item Type item object which should be saved
@param boolean $fetch True if the new ID should be returned in the item
Adds or updates a type item object .