[pLog-svn] r2501 - plog/trunk/class/gallery/dao
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Tue Sep 20 19:07:47 GMT 2005
Author: oscar
Date: 2005-09-20 19:07:47 +0000 (Tue, 20 Sep 2005)
New Revision: 2501
Modified:
plog/trunk/class/gallery/dao/galleryresources.class.php
Log:
implemented the updateResource method, so that counters on both the new and old album are updated (boy do I wish we had proper db triggers in mysql!!)
Modified: plog/trunk/class/gallery/dao/galleryresources.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresources.class.php 2005-09-20 19:06:51 UTC (rev 2500)
+++ plog/trunk/class/gallery/dao/galleryresources.class.php 2005-09-20 19:07:47 UTC (rev 2501)
@@ -663,6 +663,9 @@
*/
function updateResource( $resource )
{
+ // loads the previous version of this object
+ $prevVersion = $this->getResource( $resource->getId());
+
if( $result = $this->update( $resource )) {
// if update ok, reset the caches
$this->_cache->removeData( $resource->getId(), CACHE_RESOURCES );
@@ -674,6 +677,11 @@
$album = $resource->getAlbum();
$album->setNumResources( $album->getNumResources() + 1 );
$albums->updateAlbum( $album );
+
+ // update the counters of the previous album
+ $prevAlbum = $prevVersion->getAlbum();
+ $prevAlbum->setNumResources( $prevAlbum->getNumResources() - 1 );
+ $albums->updateAlbum( $prevAlbum );
}
return( $result );
@@ -688,7 +696,7 @@
*/
function deleteResource( $resourceId, $ownerId = -1 )
{
- // first, get informaiton abotu the resource
+ // first, get information about the resource
$resource = $this->getResource( $resourceId, $ownerId );
if( $resource ) {
$this->delete( "id", $resourceId );
More information about the pLog-svn
mailing list