diff options
author | Andreas Unterkircher <unki@netshadow.at> | 2008-01-13 10:57:43 +0100 |
---|---|---|
committer | Andreas Unterkircher <unki@netshadow.at> | 2008-01-13 10:57:43 +0100 |
commit | 1dc0e2e565d3c8b49e1074acd5875ffb63b085c9 (patch) | |
tree | c5836b90c4789a9848edef88c404143058a92f43 /phpfspot.class.php | |
parent | 642996d363598ad9b919f261e39c04f25ebabeb1 (diff) |
issue98, add function to clean up phpfspot database
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r-- | phpfspot.class.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php index 826fafd..837e3e1 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -2370,6 +2370,40 @@ class PHPFSPOT { } // check_config_options() + /** + * cleanup phpfspot own database + * + * When photos are getting delete from F-Spot, there will remain + * remain some residues in phpfspot own database. This function + * will try to wipe them out. + */ + public function cleanup_phpfspot_db() + { + $to_delete = Array(); + + $result = $this->cfg_db->db_query(" + SELECT img_idx + FROM images + ORDER BY img_idx ASC + "); + + while($row = $this->cfg_db->db_fetch_object($result)) { + if(!$this->db->db_fetchSingleRow(" + SELECT id + FROM photos + WHERE id='". $row['img_idx'] ."'")) { + + array_push($to_delete, $row['img_idx'], ','); + } + } + + $this->cfg_db->db_exec(" + DELETE FROM images + WHERE img_idx IN (". implode($to_delete) .") + "); + + } // cleanup_phpfspot_db() + } // class PHPFSPOT ?> |