Thread: [Cs-project-svn_notify] SF.net SVN: cs-project: [652] trunk/lib/tagClass.php
Brought to you by:
crazedsanity
From: <cra...@us...> - 2007-11-21 16:51:44
|
Revision: 652 http://cs-project.svn.sourceforge.net/cs-project/?rev=652&view=rev Author: crazedsanity Date: 2007-11-21 08:51:23 -0800 (Wed, 21 Nov 2007) Log Message: ----------- Tags returned in a complex array with better ordering. /lib/tagClass.php: * get_tag_list(): -- primary ordering by modifier; secondarily by lower(name) -- data retrieved by cs_phpDB::farray_fieldnames() instead of cs_phpDB::farray_nvp() (the returned array is more complex). Modified Paths: -------------- trunk/lib/tagClass.php Modified: trunk/lib/tagClass.php =================================================================== --- trunk/lib/tagClass.php 2007-11-21 16:45:44 UTC (rev 651) +++ trunk/lib/tagClass.php 2007-11-21 16:51:23 UTC (rev 652) @@ -4,11 +4,11 @@ * * SVN INFORMATION::: * ------------------ - * SVN Signature::::::: $Id$ - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ + * SVN Signature::::::: $Id:tagClass.php 626 2007-11-20 16:54:11Z crazedsanity $ + * Last Author::::::::: $Author:crazedsanity $ + * Current Revision:::: $Revision:626 $ + * Repository Location: $HeadURL:https://cs-project.svn.sourceforge.net/svnroot/cs-project/trunk/lib/tagClass.php $ + * Last Updated:::::::: $Date:2007-11-20 10:54:11 -0600 (Tue, 20 Nov 2007) $ * * * Class for tagging items, so they can be viewed in a different way: this way, for items pertaining to @@ -54,7 +54,7 @@ * @return (exception) database error or no rows. */ public function get_tag_list() { - $sql = "SELECT * FROM tag_name_table ORDER BY lower(name)"; + $sql = "SELECT * FROM tag_name_table ORDER BY modifier, lower(name)"; $numrows = $this->db->exec($sql); $dberror = $this->db->errorMsg(); @@ -67,7 +67,7 @@ } else { //good to go! - $data = $this->db->farray_nvp("tag_name_id", "name"); + $data = $this->db->farray_fieldnames("tag_name_id", NULL, 0); return($data); } }//end get_tag_list() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2007-11-23 17:23:13
|
Revision: 673 http://cs-project.svn.sourceforge.net/cs-project/?rev=673&view=rev Author: crazedsanity Date: 2007-11-23 09:23:11 -0800 (Fri, 23 Nov 2007) Log Message: ----------- Ordering options for tags, ability to change modifier for tag name. /lib/tagClass.php: * get_tag_list(): -- ARG CHANGE: NEW ARG: #2 ($orderByMod=TRUE) -- new argument determines if primary ordering is done by modifier. * update_tag_record(): -- force first argument to be an array. * update_tag_name_record() [NEW]: -- same as update_tag_record(), but using different table. * update_tag_modifier() [NEW]: -- wrapper for update_tag_name_record() to change modifier. Modified Paths: -------------- trunk/lib/tagClass.php Modified: trunk/lib/tagClass.php =================================================================== --- trunk/lib/tagClass.php 2007-11-23 17:19:39 UTC (rev 672) +++ trunk/lib/tagClass.php 2007-11-23 17:23:11 UTC (rev 673) @@ -53,8 +53,12 @@ * @return (array) PASS: contains tag_name_id=>name array. * @return (exception) database error or no rows. */ - public function get_tag_list($getAllData=FALSE) { - $sql = "SELECT * FROM tag_name_table ORDER BY modifier, lower(name)"; + public function get_tag_list($getAllData=FALSE, $orderByMod=TRUE) { + $orderBy = "ORDER BY lower(name)"; + if($orderByMod) { + $orderBy = "ORDER BY modifier, lower(name)"; + } + $sql = "SELECT * FROM tag_name_table ". $orderBy; $numrows = $this->db->exec($sql); $dberror = $this->db->errorMsg(); @@ -285,7 +289,7 @@ //========================================================================= - private function update_tag_record($critArr, array $changes) { + private function update_tag_record(array $critArr, array $changes) { $updateStr = string_from_array($changes, 'update'); $criteria = string_from_array($critArr, 'select', NULL, 'numeric'); $sql = "UPDATE tag_table SET ". $updateStr ."" . @@ -440,6 +444,53 @@ return($retval); }//end create_new_tag_name() //========================================================================= + + + + //========================================================================= + private function update_tag_name_record(array $critArr, array $changes) { + $updateStr = string_from_array($changes, 'update'); + $criteria = string_from_array($critArr, 'select', NULL, 'numeric'); + $sql = "UPDATE tag_name_table SET ". $updateStr ."" . + "WHERE ". $criteria; + + //start a transaction & run the update. + $numrows = $this->db->exec($sql); + $this->lastError = $this->db->errorMsg(); + + if(strlen($this->lastError) || $numrows !== 1) { + //something bad happened. + $retval = 0; + if(strlen($this->lastError)) { + //make it apparent that something went wrong. + $this->logsObj->log_dberror(__METHOD__ .": unable to update ($numrows) or dberror::: ". $this->lastError); + $retval = NULL; + } + } + else { + //good to go. + $retval = $numrows; + $this->logsObj->log_by_class("Updated tag record::: ". $updateStr ."\nCRITERIA::: ". $criteria, 'system'); + } + + return($retval); + }//end update_tag_name_record() + //========================================================================= + + + + //========================================================================= + public function update_tag_modifier($tagNameId, $modifier) { + if(is_numeric($tagNameId) && is_numeric($modifier)) { + $retval = $this->update_tag_name_record(array('tag_name_id' => $tagNameId), array('modifier' => $modifier)); + } + else { + throw new exception(__METHOD__ .": invalid input given..."); + } + + return($retval); + }//end update_tag_modifier() + //========================================================================= } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-01-07 23:20:49
|
Revision: 734 http://cs-project.svn.sourceforge.net/cs-project/?rev=734&view=rev Author: crazedsanity Date: 2008-01-07 15:20:45 -0800 (Mon, 07 Jan 2008) Log Message: ----------- Minor update to logging details. /lib/tagClass.php: * update_record_position_for_tag(): -- when an error occurs, indicate currentPosition. Modified Paths: -------------- trunk/lib/tagClass.php Modified: trunk/lib/tagClass.php =================================================================== --- trunk/lib/tagClass.php 2007-12-28 16:03:06 UTC (rev 733) +++ trunk/lib/tagClass.php 2008-01-07 23:20:45 UTC (rev 734) @@ -376,7 +376,7 @@ //make sure we didn't encounter a nasty internal error... if(is_null($currentPosition) || !is_numeric($currentPosition)) { //what can we do? - $details = __METHOD__ .": couldn't find current position for tagId=(". $tagId .")"; + $details = __METHOD__ .": couldn't find current position for tagId=(". $tagId ."): ". $currentPosition; $this->logsObj->log_dberror($details); throw new exception($details); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |