Thread: [Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[190] trunk/0.4/abstract/cs_singleTableHandler. a
Status: Beta
Brought to you by:
crazedsanity
From: <cra...@us...> - 2011-01-06 01:38:47
|
Revision: 190 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=190&view=rev Author: crazedsanity Date: 2011-01-06 01:38:41 +0000 (Thu, 06 Jan 2011) Log Message: ----------- Default ordering. /abstract/cs_singleTableHandler.abstract.class.php: * get_records(): -- set default "ORDER BY" clause to be the primary key's column. 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-06 00:59:29 UTC (rev 189) +++ trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-01-06 01:38:41 UTC (rev 190) @@ -182,7 +182,7 @@ } } - $orderByStr = ''; + $orderByStr = ' ORDER BY '. $this->pkeyField; if(is_string($orderBy) && strlen($orderBy)) { $orderByStr = ' ORDER BY '. $orderBy; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <cra...@us...> - 2011-02-07 19:37:18
|
Revision: 207 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=207&view=rev Author: crazedsanity Date: 2011-02-07 19:37:12 +0000 (Mon, 07 Feb 2011) Log Message: ----------- Minor change to keep values deemed as empty from being removed from the SQL. /abstract/cs_singleTableHandler.abstract.class.php: * create_record(): -- ARG CHANGE: NEW ARG: #2 ($removeEmptyVals=TRUE) -- pass new arg to cs_globalFunctions::string_from_array() 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-02-01 03:58:32 UTC (rev 206) +++ trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-02-07 19:37:12 UTC (rev 207) @@ -81,10 +81,10 @@ * @RETURN (int) SUCCESS: the (int) is the last inserted ID. * @EXCEPTION FAIL: exception indicates the error. */ - public function create_record(array $data) { + public function create_record(array $data, $removeEmptyVals=TRUE) { if(is_array($data) && count($data)) { $sql = 'INSERT INTO '. $this->tableName .' ' - . $this->gfObj->string_from_array($data, 'insert', null, $this->cleanStringArr, true); + . $this->gfObj->string_from_array($data, 'insert', null, $this->cleanStringArr, $removeEmptyVals); try { $newId = $this->dbObj->run_insert($sql, $this->seqName); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2011-05-10 23:57:36
|
Revision: 213 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=213&view=rev Author: crazedsanity Date: 2011-05-10 23:57:30 +0000 (Tue, 10 May 2011) Log Message: ----------- Fix a couple of bugs (typos), optional argument for retrieving records. /abstract/cs_singleTableHandler.abstract.class.php: * get_records_using_custom_filter(): -- fix typo with $orderByStr (one reference was $orderBYStr) -- remove invalid $ (was "$is_string(...") -- fix query so $filter doesn't have to contain " WHERE " * update_record(): -- ARG CHANGE: NEW ARG: #4 ($appendToUpdateString=null) -- optionally add an extra bit of text to the 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-04-03 18:17:47 UTC (rev 212) +++ trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-05-10 23:57:30 UTC (rev 213) @@ -236,12 +236,12 @@ } } - $orderBYStr = ' ORDER BY '. $this->pkeyField; - if($is_string($orderBy) && strlen($orderBy)) { + $orderByStr = ' ORDER BY '. $this->pkeyField; + if(is_string($orderBy) && strlen($orderBy)) { $orderByStr = ' ORDER BY '. $orderBy; } - $sql = 'SELECT * FROM '. $this->tableName . $filter . $orderByStr . $limitOffsetStr; + $sql = 'SELECT * FROM '. $this->tableName ." WHERE ". $filter . $orderByStr . $limitOffsetStr; try { $data = $this->dbObj->run_query($sql, $this->pkeyField); } @@ -268,7 +268,7 @@ * @RETURN (int) SUCCESS: (int) is the number of records updated (should always be 1) * @EXCEPTION FAIL: exception indicates the error. */ - public function update_record($recId, array $updates, $removeEmptyVals=true) { + public function update_record($recId, array $updates, $removeEmptyVals=true, $appendToUpdateString=null) { if(is_numeric($recId) && $recId >= 0 && is_array($updates) && count($updates) > 0) { $updateString = $this->gfObj->string_from_array($updates, 'update', null, $this->cleanStringArr, $removeEmptyVals); if(is_null($updateString) || !strlen($updateString) || strlen($updateString) < 3) { @@ -276,7 +276,7 @@ } else { $sql = 'UPDATE '. $this->tableName .' SET ' - . $updateString + . $updateString . $appendToUpdateString .' WHERE '. $this->pkeyField .'='. $recId; try { $retval = $this->dbObj->run_update($sql, true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |