[Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[186] trunk/0.3/abstract/cs_singleTableHandler. a
Status: Beta
Brought to you by:
crazedsanity
From: <cra...@us...> - 2010-09-09 02:42:00
|
Revision: 186 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=186&view=rev Author: crazedsanity Date: 2010-09-09 02:41:54 +0000 (Thu, 09 Sep 2010) Log Message: ----------- Allow deleting of records. NOTE::: there is no logic for only allowing a single record to get deleted, and no transaction support (see TODO). /abstract/cs_singleTableHandler.abstract.class.php: * delete_record() [NEW]: -- allow deleting of record(s). -- see important TODO; this will hopefully be added in the near future. Modified Paths: -------------- trunk/0.3/abstract/cs_singleTableHandler.abstract.class.php Modified: trunk/0.3/abstract/cs_singleTableHandler.abstract.class.php =================================================================== --- trunk/0.3/abstract/cs_singleTableHandler.abstract.class.php 2010-09-02 14:35:30 UTC (rev 185) +++ trunk/0.3/abstract/cs_singleTableHandler.abstract.class.php 2010-09-09 02:41:54 UTC (rev 186) @@ -246,6 +246,29 @@ return($retval); }//end update_record() //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * TODO: only allow 1 record to be deleted, or a specific number of records (add transaction logic)? + */ + public function delete_record($recId) { + if(is_numeric($recId)) { + $sql = "DELETE FROM ". $this->tableName ." WHERE ". $this->pkeyField ."=". $recId; + try { + $result = $this->dbObj->run_update($sql); + } + catch(Exception $e) { + throw new exception(__METHOD__ .": failed to delete record, DETAILS::: ". $e->getMessage()); + } + } + else { + throw new exception(__METHOD__ .":: failed to delete record, invalid data (". $recId .")"); + } + return($result); + }//end delete_record() + //------------------------------------------------------------------------- } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |