[phpwebapp-commits] CVS: web_app/database class.EditableRS.php,1.6,1.6.2.1 class.PagedRS.php,1.6,1.6
Brought to you by:
dashohoxha
Update of /cvsroot/phpwebapp/web_app/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5614/database Modified Files: Tag: phpwebapp-1_0 class.EditableRS.php class.PagedRS.php class.Recordset.php class.StaticRS.php class.TableRS.php package.DB.php Log Message: All the changes that are done after release 1.0 (but without the XML parser and XHML template requirement) are placed in the branch phpwebapp-1_0, so that old applications can get them, without having to modify their templates. Index: class.EditableRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.EditableRS.php,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** class.EditableRS.php 25 Aug 2003 13:18:32 -0000 1.6 --- class.EditableRS.php 4 Oct 2004 09:09:32 -0000 1.6.2.1 *************** *** 226,229 **** --- 226,231 ---- function addCol($fld_name, $default_value =UNDEFINED) { + if (isset($this->content[0][$fld_name])) return; + for ($i=0; $i < $this->count; $i++) { *************** *** 231,234 **** --- 233,256 ---- } } + + /** + * Change the name of a column. + */ + function renameCol($fld_name, $new_fld_name) + { + if (isset($this->content[0][$new_fld_name])) + { + $msg = "EditableRS::renameCol(): there is already" + . " a field named '$new_fld_name'.\n"; + print WebApp::error_msg($msg); + return; + } + + for ($i=0; $i < $this->count; $i++) + { + $this->content[$i][$new_fld_name] = $this->content[$i][$fld_name]; + unset($this->content[$i][$fld_name]); + } + } } ?> \ No newline at end of file Index: class.PagedRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.PagedRS.php,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** class.PagedRS.php 25 Aug 2003 13:18:32 -0000 1.6 --- class.PagedRS.php 4 Oct 2004 09:09:32 -0000 1.6.2.1 *************** *** 21,25 **** ! include_once DB_PATH."class.Recordset.php"; /** --- 21,25 ---- ! include_once DB_PATH."class.EditableRS.php"; /** *************** *** 31,35 **** * @package database */ ! class PagedRS extends Recordset { /** --- 31,35 ---- * @package database */ ! class PagedRS extends EditableRS { /** *************** *** 48,52 **** function PagedRS($id, $query =UNDEFINED, $rp =UNDEFINED, $conn =UNDEFINED) { ! $this->Recordset($id, $query, $conn); $this->type = "PagedRS"; $this->recs_per_page = ($rp==UNDEFINED ? 0 : $rp); --- 48,52 ---- function PagedRS($id, $query =UNDEFINED, $rp =UNDEFINED, $conn =UNDEFINED) { ! $this->EditableRS($id, $query, $conn); $this->type = "PagedRS"; $this->recs_per_page = ($rp==UNDEFINED ? 0 : $rp); *************** *** 70,80 **** /** Executes the query and puts the result into $this->content. */ ! function Open($cp ="default", $rp ="default", $query ="default") { ! global $cnn; ! ! if ($query<>"default") $this->query = $query; ! if ($rp<>"default") $this->recs_per_page = $rp; ! if ($cp=="default") { //default is to get it from SVars --- 70,82 ---- /** Executes the query and puts the result into $this->content. */ ! function Open($cp =UNDEFINED, $conn =UNDEFINED) { ! if ($this->opened) ! { ! $this->MoveFirst(); ! return; //don't open it a second time ! } ! ! if ($cp==UNDEFINED) { //default is to get it from SVars *************** *** 87,91 **** $this->nr_of_recs = $this->get_nr_of_recs(); $nr_of_pages = ceil($this->nr_of_recs / $this->recs_per_page); ! if ($this->current_page>$nr_of_pages) $this->current_page=$nr_of_pages; //modify and execute the query --- 89,93 ---- $this->nr_of_recs = $this->get_nr_of_recs(); $nr_of_pages = ceil($this->nr_of_recs / $this->recs_per_page); ! if ($this->current_page > $nr_of_pages) $this->current_page = $nr_of_pages; //modify and execute the query *************** *** 93,101 **** $query = WebApp::replaceVars($this->query); $query .= " LIMIT $first_rec_idx, ".$this->recs_per_page; ! $result = $this->cnn->execQuery($query); $this->content = $result; $this->count = count($result); $this->pos = 0; } --- 95,111 ---- $query = WebApp::replaceVars($this->query); $query .= " LIMIT $first_rec_idx, ".$this->recs_per_page; ! if ($conn==UNDEFINED) ! { ! $result = $this->cnn->execQuery($query, $this->ID); ! } ! else ! { ! $result = $conn->execQuery($query, $this->ID); ! } $this->content = $result; $this->count = count($result); $this->pos = 0; + $this->opened = true; } *************** *** 162,167 **** $query = WebApp::replaceVars($this->query); $query = $this->get_count_query($query); ! $rs = new Recordset; ! $rs->Open($query); $nrRecs = $rs->Field("COUNT_OF_RECS"); --- 172,177 ---- $query = WebApp::replaceVars($this->query); $query = $this->get_count_query($query); ! $rs = new Recordset($this->ID."_countQuery", $query); ! $rs->Open(); $nrRecs = $rs->Field("COUNT_OF_RECS"); Index: class.Recordset.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.Recordset.php,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** class.Recordset.php 25 Aug 2003 13:18:32 -0000 1.7 --- class.Recordset.php 4 Oct 2004 09:09:32 -0000 1.7.2.1 *************** *** 81,85 **** } ! /** Returns the value of the field given as parameter. */ function Field($fld_name) { --- 81,88 ---- } ! /** ! * Returns the value of the given field. ! * Returns UNDEFINED if there is no such field, or EOF or BOF. ! */ function Field($fld_name) { *************** *** 103,107 **** $this->ID = $id; $this->query = $query; ! $this->cnn = ($conn==UNDEFINED ? $cnn : $conn); $this->content = array(); $this->count = 0; --- 106,117 ---- $this->ID = $id; $this->query = $query; ! if ($conn==UNDEFINED) ! { ! $this->cnn = &$cnn; ! } ! else ! { ! $this->cnn = $conn; ! } $this->content = array(); $this->count = 0; *************** *** 110,117 **** } ! /** Executes the query and puts the result into $this->content. */ ! function Open($q =UNDEFINED) { - if ($q<>UNDEFINED) $this->query = $q; $query = $this->query; if ($query==UNDEFINED) return; --- 120,129 ---- } ! /** ! * Executes the query and puts the result into $this->content. ! * If $conn is given, it is used instead of its own connection. ! */ ! function Open($conn =UNDEFINED) { $query = $this->query; if ($query==UNDEFINED) return; *************** *** 120,124 **** $query = WebApp::replaceVars($query); ! $result = $this->cnn->execQuery($query, $this->ID); if (is_array($result)) { --- 132,144 ---- $query = WebApp::replaceVars($query); ! if ($conn==UNDEFINED) ! { ! $result = $this->cnn->execQuery($query, $this->ID); ! } ! else ! { ! $result = $conn->execQuery($query, $this->ID); ! } ! if (is_array($result)) { *************** *** 126,129 **** --- 146,150 ---- $this->count = count($result); $this->pos = 0; + return; } else Index: class.StaticRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.StaticRS.php,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** class.StaticRS.php 25 Aug 2003 13:18:32 -0000 1.5 --- class.StaticRS.php 4 Oct 2004 09:09:32 -0000 1.5.2.1 *************** *** 44,48 **** } ! function Open() { if ($this->opened) --- 44,48 ---- } ! function Open($conn =UNDEFINED) { if ($this->opened) *************** *** 51,55 **** return; //don't open it a second time } ! if ($this->query<>"") Recordset::Open(); $this->opened = true; } --- 51,55 ---- return; //don't open it a second time } ! if ($this->query<>"") Recordset::Open($conn); $this->opened = true; } Index: class.TableRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.TableRS.php,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** class.TableRS.php 25 Aug 2003 13:18:32 -0000 1.5 --- class.TableRS.php 4 Oct 2004 09:09:32 -0000 1.5.2.1 *************** *** 21,25 **** ! include_once DB_PATH."class.Recordset.php"; /** --- 21,25 ---- ! include_once DB_PATH."class.EditableRS.php"; /** Index: package.DB.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/package.DB.php,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** package.DB.php 25 Aug 2003 13:18:32 -0000 1.5 --- package.DB.php 4 Oct 2004 09:09:32 -0000 1.5.2.1 *************** *** 40,50 **** break; } - include_once DB_PATH."class.$CnnType.php"; - - include_once DB_PATH."class.Recordset.php"; - include_once DB_PATH."class.PagedRS.php"; - include_once DB_PATH."class.StaticRS.php"; - include_once DB_PATH."class.TableRS.php"; /** --- 40,44 ---- *************** *** 55,62 **** * can create and use other connections as well, or override this one. */ $cnn = new $CnnType; } include_once DB_PATH."class.EditableRS.php"; ! ! ?> \ No newline at end of file --- 49,60 ---- * can create and use other connections as well, or override this one. */ + include_once CONFIG_PATH."const.DB.php"; $cnn = new $CnnType; } + include_once DB_PATH."class.Recordset.php"; + include_once DB_PATH."class.StaticRS.php"; include_once DB_PATH."class.EditableRS.php"; ! include_once DB_PATH."class.PagedRS.php"; ! include_once DB_PATH."class.TableRS.php"; ! ?> |