[Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[200] trunk/0.4/abstract/cs_singleTableHandler. a
Status: Beta
Brought to you by:
crazedsanity
From: <cra...@us...> - 2011-01-27 05:05:02
|
Revision: 200 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=200&view=rev Author: crazedsanity Date: 2011-01-27 05:04:56 +0000 (Thu, 27 Jan 2011) Log Message: ----------- Minor logic fixes, new method to match method from cs_phpDB. /abstract/cs_singleTableHandler.abstract.class.php: * get_record_by_id(): -- return just the sub-array (field=>value) * get_single_record(): -- return just the sub-array (field=>value) * update_record(): -- remove commented-out debug stuff. * get_last_query() [NEW]: -- return value from cs_phpDB::get_last_query(). Modified Paths: -------------- trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php Modified: trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php =================================================================== --- trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-01-27 04:04:11 UTC (rev 199) +++ trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-01-27 05:04:56 UTC (rev 200) @@ -114,6 +114,12 @@ if(is_numeric($recId)) { try { $data = $this->get_records(array($this->pkeyField => $recId)); + if(isset($data[$recId])) { + $data = $data[$recId]; + } + else { + throw new exception(__METHOD__ .": returned data did not contain ID (". $recId .")"); + } } catch(Exception $e) { throw new exception(__METHOD__ .":: error while retrieving record (". $recId ."), DETAILS::: ". $e->getMessage()); @@ -142,8 +148,14 @@ try { $data = $this->get_records($filter, null, 1); - $keys = array_keys($data); - $retval = $data[$keys[0]]; + if(is_array($data)) { + $keys = array_keys($data); + $retval = $data[$keys[0]]; + } + else { + //technically, the call to get_records() got boolean(false) from cs_phpDB::run_query(), so we could just return $data directly... + $retval = false; + } } catch(Exception $e) { throw new exception(__METHOD__ .":: failed to retrieve record, DETAILS::: ". $e->getMessage()); @@ -233,7 +245,6 @@ .' WHERE '. $this->pkeyField .'='. $recId; try { $retval = $this->dbObj->run_update($sql, true); -#$this->gfObj->debug_print(__METHOD__ .":: retval=(". $retval ."), SQL::: ". $sql ,1); } catch(Exception $e) { throw new exception(__METHOD__ .":: failed to update record (". $recId ."), DETAILS::: ". $e->getMessage()); @@ -269,6 +280,14 @@ return($result); }//end delete_record() //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_last_query() { + return($this->dbObj->get_last_query()); + }//end get_last_query(); + //------------------------------------------------------------------------- } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |