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

		if( $item->getId() === null ) {
			throw new MShop_Locale_Exception( sprintf( 'Newly created site can not be saved using method "saveItem()". Try using method "insertItem()" instead.' ) );
		}

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


		$context = $this->_getContext();

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

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

			$path = 'mshop/locale/manager/site/default/item/update';
			$stmt = $this->_getCachedStatement( $conn, $path );

			$stmt->bind(1, $item->getCode(), MW_DB_Statement_Abstract::PARAM_STR);
			$stmt->bind(2, $item->getLabel(), MW_DB_Statement_Abstract::PARAM_STR);
			$stmt->bind(3, json_encode($item->getConfig()), MW_DB_Statement_Abstract::PARAM_STR);
			$stmt->bind(4, $item->getStatus(), MW_DB_Statement_Abstract::PARAM_INT);
			$stmt->bind(5, $context->getEditor() );
			$stmt->bind(6, date( 'Y-m-d H:i:s', time() ) ); // mtime
			$stmt->bind(7, $id, MW_DB_Statement_Abstract::PARAM_INT);

			$stmt->execute()->finish();
			$item->setId( $id ); // set 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_Locale_Item_Site_Interface';
		if ( !( $item instanceof $iface ) ) {
			throw new MShop_Locale_Exception(sprintf('Object is not of required type "%1$s"', $iface));
		}

		if( $item->getId() === null ) {
			throw new MShop_Locale_Exception( sprintf( 'Newly created site can not be saved using method "saveItem()". Try using method "insertItem()" instead.' ) );
		}

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


		$context = $this->_getContext();

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

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

			$path = 'mshop/locale/manager/site/default/item/update';
			$stmt = $this->_getCachedStatement( $conn, $path );

			$stmt->bind(1, $item->getCode(), MW_DB_Statement_Abstract::PARAM_STR);
			$stmt->bind(2, $item->getLabel(), MW_DB_Statement_Abstract::PARAM_STR);
			$stmt->bind(3, json_encode($item->getConfig()), MW_DB_Statement_Abstract::PARAM_STR);
			$stmt->bind(4, $item->getStatus(), MW_DB_Statement_Abstract::PARAM_INT);
			$stmt->bind(5, $context->getEditor() );
			$stmt->bind(6, date( 'Y-m-d H:i:s', time() ) ); // mtime
			$stmt->bind(7, $id, MW_DB_Statement_Abstract::PARAM_INT);

			$stmt->execute()->finish();
			$item->setId( $id ); // set 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_Locale_Item_Site_Interface' ; if ( ! ( $ item instanceof $ iface ) ) { throw new MShop_Locale_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ iface ) ) ; } if ( $ item -> getId ( ) === null ) { throw new MShop_Locale_Exception ( sprintf ( 'Newly created site can not be saved using method "saveItem()". Try using method "insertItem()" instead.' ) ) ; } if ( ! $ item -> isModified ( ) ) { return ; } $ context = $ this -> _getContext ( ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ id = $ item -> getId ( ) ; $ path = 'mshop/locale/manager/site/default/item/update' ; $ stmt = $ this -> _getCachedStatement ( $ conn , $ path ) ; $ stmt -> bind ( 1 , $ item -> getCode ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ stmt -> bind ( 2 , $ item -> getLabel ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ stmt -> bind ( 3 , json_encode ( $ item -> getConfig ( ) ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ stmt -> bind ( 4 , $ item -> getStatus ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 5 , $ context -> getEditor ( ) ) ; $ stmt -> bind ( 6 , date ( 'Y-m-d H:i:s' , time ( ) ) ) ; // mtime $ stmt -> bind ( 7 , $ id , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> execute ( ) -> finish ( ) ; $ item -> setId ( $ id ) ; // set Modified false $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } }
Adds a new site to the storage or updates an existing one.

@param MShop_Common_Item_Interface $item New site item for saving to the storage
@param boolean $fetch True if the new ID should be returned in the item
@throws MShop_Locale_Exception
Adds a new site to the storage or updates an existing one .