Thread: [phpwebapp-commits] CVS: web_app/database package.DB.php,1.9,1.10 class.TableRS.php,1.6,1.7 class.St
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-07-22 16:25:50
|
Update of /cvsroot/phpwebapp/web_app/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9224/database Modified Files: package.DB.php class.TableRS.php class.StaticRS.php class.Recordset.php class.PagedRS.php class.MySQLCnn.php class.EditableRS.php class.Connection.php Log Message: reformated and modified the copyleft notice Index: package.DB.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/package.DB.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** package.DB.php 14 Jul 2004 14:45:41 -0000 1.9 --- package.DB.php 22 Jul 2004 16:25:38 -0000 1.10 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Index: class.TableRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.TableRS.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** class.TableRS.php 8 Sep 2003 13:18:24 -0000 1.6 --- class.TableRS.php 22 Jul 2004 16:25:38 -0000 1.7 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 34,47 **** { function TableRS() ! { ! } function commit() ! { ! } function abord() ! { ! } } ?> \ No newline at end of file --- 35,48 ---- { function TableRS() ! { ! } function commit() ! { ! } function abord() ! { ! } } ?> \ No newline at end of file Index: class.StaticRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.StaticRS.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** class.StaticRS.php 8 Sep 2003 13:18:24 -0000 1.6 --- class.StaticRS.php 22 Jul 2004 16:25:38 -0000 1.7 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 38,57 **** function StaticRS($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) ! { ! $this->Recordset($id, $query, $conn); ! $this->type = "StaticRS"; ! $this->opened = false; ! } function Open($conn =UNDEFINED) ! { ! if ($this->opened) ! { ! $this->MoveFirst(); ! return; //don't open it a second time ! } ! if ($this->query<>"") Recordset::Open($conn); ! $this->opened = true; ! } /** --- 39,58 ---- function StaticRS($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) ! { ! $this->Recordset($id, $query, $conn); ! $this->type = "StaticRS"; ! $this->opened = false; ! } function Open($conn =UNDEFINED) ! { ! if ($this->opened) ! { ! $this->MoveFirst(); ! return; //don't open it a second time ! } ! if ($this->query<>"") Recordset::Open($conn); ! $this->opened = true; ! } /** Index: class.Recordset.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.Recordset.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** class.Recordset.php 22 Jul 2004 09:41:25 -0000 1.12 --- class.Recordset.php 22 Jul 2004 16:25:38 -0000 1.13 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 52,83 **** function EOF() ! { ! return $this->pos >= $this->count; ! } function BOF() ! { ! return $this->pos < 0; ! } function MoveNext() ! { ! if ( !$this->EOF() ) $this->pos++; ! } function MovePrev() ! { ! if ( !$this->BOF() ) $this->pos--; ! } function MoveFirst() ! { ! $this->pos = 0; ! } function MoveLast() ! { ! $this->pos = $this->count - 1; ! } /** --- 53,84 ---- function EOF() ! { ! return $this->pos >= $this->count; ! } function BOF() ! { ! return $this->pos < 0; ! } function MoveNext() ! { ! if ( !$this->EOF() ) $this->pos++; ! } function MovePrev() ! { ! if ( !$this->BOF() ) $this->pos--; ! } function MoveFirst() ! { ! $this->pos = 0; ! } function MoveLast() ! { ! $this->pos = $this->count - 1; ! } /** *************** *** 86,124 **** */ function Field($fld_name) ! { ! if ( isset($this->contents[$this->pos][$fld_name]) ) ! return $this->contents[$this->pos][$fld_name]; ! else ! return UNDEFINED; ! } /** Returns all the fields at the current position as an associated array. */ function Fields() ! { ! $fields = $this->contents[$this->pos]; ! if (!is_array($fields)) $fields = array(); ! return $fields; ! } /** Constructor */ function Recordset($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) ! { ! global $cnn; ! $this->ID = $id; ! $this->query = $query; ! if ($conn==UNDEFINED) ! { ! $this->cnn = &$cnn; ! } ! else ! { ! $this->cnn = $conn; ! } ! $this->contents = array(); ! $this->count = 0; ! $this->pos = 0; ! $this->type = "Recordset"; ! } /** --- 87,125 ---- */ function Field($fld_name) ! { ! if ( isset($this->contents[$this->pos][$fld_name]) ) ! return $this->contents[$this->pos][$fld_name]; ! else ! return UNDEFINED; ! } /** Returns all the fields at the current position as an associated array. */ function Fields() ! { ! $fields = $this->contents[$this->pos]; ! if (!is_array($fields)) $fields = array(); ! return $fields; ! } /** Constructor */ function Recordset($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) ! { ! global $cnn; ! $this->ID = $id; ! $this->query = $query; ! if ($conn==UNDEFINED) ! { ! $this->cnn = &$cnn; ! } ! else ! { ! $this->cnn = $conn; ! } ! $this->contents = array(); ! $this->count = 0; ! $this->pos = 0; ! $this->type = "Recordset"; ! } /** *************** *** 127,165 **** */ function Open($conn =UNDEFINED) ! { ! $query = $this->query; ! if ($query==UNDEFINED) return; ! $this->Close(); //empty the content ! $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)) ! { ! $this->contents = $result; ! $this->count = count($result); ! $this->pos = 0; ! return; ! } ! else ! { ! return $result; ! } ! } function Close() ! { ! if (isset($this->contents)) unset($this->contents); ! $this->count = 0; ! $this->pos = 0; ! } /** --- 128,166 ---- */ function Open($conn =UNDEFINED) ! { ! $query = $this->query; ! if ($query==UNDEFINED) return; ! $this->Close(); //empty the content ! $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)) ! { ! $this->contents = $result; ! $this->count = count($result); ! $this->pos = 0; ! return; ! } ! else ! { ! return $result; ! } ! } function Close() ! { ! if (isset($this->contents)) unset($this->contents); ! $this->count = 0; ! $this->pos = 0; ! } /** *************** *** 168,191 **** */ function slice($offset =0, $length =UNDEFINED) ! { ! $slice = array(); ! if ($length===UNDEFINED) ! { ! $slice = array_slice($this->contents, $offset); ! } ! else ! { ! $slice = array_slice($this->contents, $offset, $length); ! } ! //create a new recordset of the same type as this ! $rs = new $this->type; ! $rs->contents = $slice; ! $rs->count = sizeof($slice); ! $rs->pos = 0; ! return $rs; ! } /** --- 169,192 ---- */ function slice($offset =0, $length =UNDEFINED) ! { ! $slice = array(); ! if ($length===UNDEFINED) ! { ! $slice = array_slice($this->contents, $offset); ! } ! else ! { ! $slice = array_slice($this->contents, $offset, $length); ! } ! //create a new recordset of the same type as this ! $rs = new $this->type; ! $rs->contents = $slice; ! $rs->count = sizeof($slice); ! $rs->pos = 0; ! return $rs; ! } /** *************** *** 198,226 **** */ function match($condition, $pos=UNDEFINED) ! { ! //get the field name, pattern and match type from $condition ! list($fld_name,$pattern) = split("=", $condition, 2); ! $fld_name = trim($fld_name); ! $pattern = trim($pattern); ! $match_type = substr($pattern, 0, 1); //get first char ! //remove first and last chars ! $pattern = substr($pattern, 1, sizeof($pattern)-2); ! //get the field value ! if ($pos===UNDEFINED) $pos = $this->pos; ! $fld_value = $this->contents[$pos][$fld_name]; ! //match with pattern ! if ($match_type=="'") ! { ! $result = ($fld_value==$pattern); ! } ! else ! { ! $result = ereg($pattern, $fld_value); ! } ! return $result; ! } /** --- 199,227 ---- */ function match($condition, $pos=UNDEFINED) ! { ! //get the field name, pattern and match type from $condition ! list($fld_name,$pattern) = split("=", $condition, 2); ! $fld_name = trim($fld_name); ! $pattern = trim($pattern); ! $match_type = substr($pattern, 0, 1); //get first char ! //remove first and last chars ! $pattern = substr($pattern, 1, sizeof($pattern)-2); ! //get the field value ! if ($pos===UNDEFINED) $pos = $this->pos; ! $fld_value = $this->contents[$pos][$fld_name]; ! //match with pattern ! if ($match_type=="'") ! { ! $result = ($fld_value==$pattern); ! } ! else ! { ! $result = ereg($pattern, $fld_value); ! } ! return $result; ! } /** *************** *** 233,250 **** */ function filter($condition) ! { ! $rs = new $this->type; ! $rs->Open(); ! for ($i=0; $i < $this->count; $i++) ! { ! if ($this->match($condition, $i)) ! { ! $rec = $this->contents[$i]; ! $rs->addRec($rec); ! } ! } ! $rs->MoveFirst(); ! return $rs; ! } /** --- 234,251 ---- */ function filter($condition) ! { ! $rs = new $this->type; ! $rs->Open(); ! for ($i=0; $i < $this->count; $i++) ! { ! if ($this->match($condition, $i)) ! { ! $rec = $this->contents[$i]; ! $rs->addRec($rec); ! } ! } ! $rs->MoveFirst(); ! return $rs; ! } /** *************** *** 258,265 **** */ function find($condition =UNDEFINED) ! { ! if ($condition<>UNDEFINED) $this->search($condition); ! return $this->find_next(); ! } /** --- 259,266 ---- */ function find($condition =UNDEFINED) ! { ! if ($condition<>UNDEFINED) $this->search($condition); ! return $this->find_next(); ! } /** *************** *** 270,284 **** */ function search($condition) ! { ! $this->found_positions = array(); ! $this->current_found = -1; ! for ($i=0; $i < $this->count; $i++) ! { ! if ($this->match($condition, $i)) ! { ! $this->found_positions[] = $i; ! } ! } ! } /** --- 271,285 ---- */ function search($condition) ! { ! $this->found_positions = array(); ! $this->current_found = -1; ! for ($i=0; $i < $this->count; $i++) ! { ! if ($this->match($condition, $i)) ! { ! $this->found_positions[] = $i; ! } ! } ! } /** *************** *** 289,320 **** */ function find_next() ! { ! $found_nr = sizeof($this->found_positions); ! if ($this->current_found + 1 < $found_nr ) ! { ! $this->current_found += 1; ! $idx = $this->current_found; ! $this->pos = $this->found_positions[$idx]; ! return true; ! } ! else ! { ! return false; ! } ! } /** Returns an array with the values of the specified field. */ function getColumn($fld_name) ! { ! $column = array(); ! for ($i=0; $i < $this->count; $i++) ! { ! if ( isset($this->contents[$i][$fld_name]) ) ! { ! $column[] = $this->contents[$i][$fld_name]; ! } ! } ! return $column; ! } /** --- 290,321 ---- */ function find_next() ! { ! $found_nr = sizeof($this->found_positions); ! if ($this->current_found + 1 < $found_nr ) ! { ! $this->current_found += 1; ! $idx = $this->current_found; ! $this->pos = $this->found_positions[$idx]; ! return true; ! } ! else ! { ! return false; ! } ! } /** Returns an array with the values of the specified field. */ function getColumn($fld_name) ! { ! $column = array(); ! for ($i=0; $i < $this->count; $i++) ! { ! if ( isset($this->contents[$i][$fld_name]) ) ! { ! $column[] = $this->contents[$i][$fld_name]; ! } ! } ! return $column; ! } /** *************** *** 323,343 **** */ function getColumns($fld_names) ! { ! $rs = new $this->type; ! $rs->Open(); ! $arr_flds = explode(",", $fld_names); ! for ($i=0; $i < $this->count; $i++) ! { ! $rec = array(); ! for ($j=0; $j < sizeof($arr_flds); $j++) ! { ! $fld = $arr_flds[$j]; ! $rec[$fld] = $this->contents[$i][$fld]; ! } ! $rs->addRec($rec); ! } ! $rs->MoveFirst(); ! return $rs; ! } /** --- 324,344 ---- */ function getColumns($fld_names) ! { ! $rs = new $this->type; ! $rs->Open(); ! $arr_flds = explode(",", $fld_names); ! for ($i=0; $i < $this->count; $i++) ! { ! $rec = array(); ! for ($j=0; $j < sizeof($arr_flds); $j++) ! { ! $fld = $arr_flds[$j]; ! $rec[$fld] = $this->contents[$i][$fld]; ! } ! $rs->addRec($rec); ! } ! $rs->MoveFirst(); ! return $rs; ! } /** *************** *** 346,358 **** */ function toHtmlTable() ! { ! $type = $this->type; ! if ($type=="PagedRS") ! { ! $type .= "(current_page='$this->current_page'," ! ." recs_per_page='$this->recs_per_page'," ! ."nr_of_recs='$this->nr_of_recs')"; ! } ! $htmlTable = " <br /> <table border='0' cellspacing='1' cellpadding='0'> --- 347,359 ---- */ function toHtmlTable() ! { ! $type = $this->type; ! if ($type=="PagedRS") ! { ! $type .= "(current_page='$this->current_page'," ! ." recs_per_page='$this->recs_per_page'," ! ."nr_of_recs='$this->nr_of_recs')"; ! } ! $htmlTable = " <br /> <table border='0' cellspacing='1' cellpadding='0'> *************** *** 376,402 **** <table bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'> "; ! if ($this->count > 0) ! { ! $this->MoveFirst(); ! $rec = $this->Fields(); ! $htmlTable .= "\t<tr>\n"; ! while ( list($fld_name, $fld_value) = each($rec) ) ! { ! $htmlTable .= "\t\t<th bgcolor='#eeeeee'> $fld_name </th>\n"; ! } ! $htmlTable .= "\t</tr>\n"; ! while (!$this->EOF()) ! { ! $rec = $this->Fields(); ! $htmlTable .= "\t<tr>\n"; ! while ( list($fld_name, $fld_value) = each($rec) ) ! { ! $htmlTable .= "\t\t<td bgcolor='white'> $fld_value </td>\n"; ! } ! $htmlTable .= "\t</tr>\n"; ! $this->MoveNext(); ! } ! } ! $htmlTable .= " </table> </td></tr> --- 377,403 ---- <table bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'> "; ! if ($this->count > 0) ! { ! $this->MoveFirst(); ! $rec = $this->Fields(); ! $htmlTable .= "\t<tr>\n"; ! while ( list($fld_name, $fld_value) = each($rec) ) ! { ! $htmlTable .= "\t\t<th bgcolor='#eeeeee'> $fld_name </th>\n"; ! } ! $htmlTable .= "\t</tr>\n"; ! while (!$this->EOF()) ! { ! $rec = $this->Fields(); ! $htmlTable .= "\t<tr>\n"; ! while ( list($fld_name, $fld_value) = each($rec) ) ! { ! $htmlTable .= "\t\t<td bgcolor='white'> $fld_value </td>\n"; ! } ! $htmlTable .= "\t</tr>\n"; ! $this->MoveNext(); ! } ! } ! $htmlTable .= " </table> </td></tr> *************** *** 404,410 **** "; ! $this->MoveFirst(); ! return $htmlTable; ! } } ?> \ No newline at end of file --- 405,411 ---- "; ! $this->MoveFirst(); ! return $htmlTable; ! } } ?> \ No newline at end of file Index: class.PagedRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.PagedRS.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** class.PagedRS.php 22 Jul 2004 09:41:25 -0000 1.12 --- class.PagedRS.php 22 Jul 2004 16:25:38 -0000 1.13 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 47,56 **** 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); ! $this->current_page = $this->get_current_page(); ! } /** --- 48,57 ---- 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); ! $this->current_page = $this->get_current_page(); ! } /** *************** *** 59,112 **** */ function get_current_page() ! { ! $cp = WebApp::getSVar($this->ID."->current_page"); ! if ($cp==UNDEFINED) ! { ! $cp = 1; ! WebApp::setSVar($this->ID."->current_page", $cp); ! } ! return $cp; ! } /** Executes the query and puts the result into $this->contents. */ 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 ! $this->current_page = $this->get_current_page(); ! } ! else ! { ! $this->current_page = $cp; ! } ! $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 ! $first_rec_idx = ($this->current_page - 1)*$this->recs_per_page; ! $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->contents = $result; ! $this->count = count($result); ! $this->pos = 0; ! $this->opened = true; ! } /** --- 60,113 ---- */ function get_current_page() ! { ! $cp = WebApp::getSVar($this->ID."->current_page"); ! if ($cp==UNDEFINED) ! { ! $cp = 1; ! WebApp::setSVar($this->ID."->current_page", $cp); ! } ! return $cp; ! } /** Executes the query and puts the result into $this->contents. */ 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 ! $this->current_page = $this->get_current_page(); ! } ! else ! { ! $this->current_page = $cp; ! } ! $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 ! $first_rec_idx = ($this->current_page - 1)*$this->recs_per_page; ! $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->contents = $result; ! $this->count = count($result); ! $this->pos = 0; ! $this->opened = true; ! } /** *************** *** 115,156 **** */ function getPageVars() ! { ! $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; ! if ($this->current_page==$nr_of_pages) ! $next_page = "1"; //next page of the last page is the first page ! else ! $next_page = $this->current_page + 1; ! if ($this->current_page==1) ! $prev_page = 1; //previous page of the first page is the first page itself ! else ! $prev_page = $this->current_page - 1; ! $first_rec = 1 + ($this->current_page - 1)*$this->recs_per_page; ! $last_rec = $this->current_page * $this->recs_per_page; ! if ($first_rec > $this->nr_of_recs) $first_rec = $this->nr_of_recs; ! if ($last_rec > $this->nr_of_recs) $last_rec = $this->nr_of_recs; ! $page_vars = ! array( ! //the number of the first record of the page ! "FirstRec" => $first_rec, ! //the number of the last record of the page ! "LastRec" => $last_rec, ! //the number of all records that can be retrieved by the query ! "AllRecs" => $this->nr_of_recs, ! //current page of records that is retrieved ! "CurrPage" => $this->current_page, ! //the number of the next page ! "NextPage" => $next_page, ! //the number of the previous page ! "PrevPage" => $prev_page, ! //the number of the last page ! "LastPage" => $nr_of_pages ! ); ! return $page_vars; ! } /** --- 116,157 ---- */ function getPageVars() ! { ! $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; ! if ($this->current_page==$nr_of_pages) ! $next_page = "1"; //next page of the last page is the first page ! else ! $next_page = $this->current_page + 1; ! if ($this->current_page==1) ! $prev_page = 1; //previous page of the first page is the first page itself ! else ! $prev_page = $this->current_page - 1; ! $first_rec = 1 + ($this->current_page - 1)*$this->recs_per_page; ! $last_rec = $this->current_page * $this->recs_per_page; ! if ($first_rec > $this->nr_of_recs) $first_rec = $this->nr_of_recs; ! if ($last_rec > $this->nr_of_recs) $last_rec = $this->nr_of_recs; ! $page_vars = ! array( ! //the number of the first record of the page ! "FirstRec" => $first_rec, ! //the number of the last record of the page ! "LastRec" => $last_rec, ! //the number of all records that can be retrieved by the query ! "AllRecs" => $this->nr_of_recs, ! //current page of records that is retrieved ! "CurrPage" => $this->current_page, ! //the number of the next page ! "NextPage" => $next_page, ! //the number of the previous page ! "PrevPage" => $prev_page, ! //the number of the last page ! "LastPage" => $nr_of_pages ! ); ! return $page_vars; ! } /** *************** *** 159,186 **** */ function get_nr_of_recs() ! { ! //get it from session ! $nrRecs = WebApp::getSVar($this->ID."->nrRecs"); ! $recount = WebApp::getSVar($this->ID."->recount"); ! //if the number of the records is undefined ! //or the recount is requested explicitly by the application ! //find the number of recs by executing a COUNT query ! if ( ($nrRecs==UNDEFINED) ! or ($recount=="true") ) ! { ! $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"); ! //save it in session and turn off recounting ! WebApp::setSVar($this->ID."->nrRecs", $nrRecs); ! WebApp::setSVar($this->ID."->recount", "false"); ! } ! return $nrRecs; ! } /** --- 160,187 ---- */ function get_nr_of_recs() ! { ! //get it from session ! $nrRecs = WebApp::getSVar($this->ID."->nrRecs"); ! $recount = WebApp::getSVar($this->ID."->recount"); ! //if the number of the records is undefined ! //or the recount is requested explicitly by the application ! //find the number of recs by executing a COUNT query ! if ( ($nrRecs==UNDEFINED) ! or ($recount=="true") ) ! { ! $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"); ! //save it in session and turn off recounting ! WebApp::setSVar($this->ID."->nrRecs", $nrRecs); ! WebApp::setSVar($this->ID."->recount", "false"); ! } ! return $nrRecs; ! } /** *************** *** 191,219 **** */ function get_count_query($query) ! { ! $query = eregi_replace("[[:space:]]from[[:space:]]", " FROM ", $query); ! $from_pos = strpos($query, " FROM "); ! $before_from = substr($query, 0, $from_pos); ! $after_from = substr($query, $from_pos); ! if (eregi("GROUP +BY", $after_from)) ! { ! $after_from = eregi_replace("ORDER +BY.*", "", $after_from); ! eregi("GROUP +BY(.*)", $after_from, $regs); ! $group_by_fields = $regs[1]; ! $after_from = eregi_replace("GROUP +BY.*", "", $after_from); ! $count_query = "SELECT COUNT(DISTINCT $group_by_fields) AS COUNT_OF_RECS $after_from"; ! } ! else if (eregi("SELECT +DISTINCT", $before_from)) ! { ! $before_from = eregi_replace("SELECT +(DISTINCT.*)", "SELECT COUNT(\\1) AS COUNT_OF_RECS", $before_from); ! $count_query = $before_from.$after_from; ! } ! else ! { ! $count_query = "SELECT COUNT(1) AS COUNT_OF_RECS" . $after_from; ! } ! return $count_query; ! } } ?> \ No newline at end of file --- 192,220 ---- */ function get_count_query($query) ! { ! $query = eregi_replace("[[:space:]]from[[:space:]]", " FROM ", $query); ! $from_pos = strpos($query, " FROM "); ! $before_from = substr($query, 0, $from_pos); ! $after_from = substr($query, $from_pos); ! if (eregi("GROUP +BY", $after_from)) ! { ! $after_from = eregi_replace("ORDER +BY.*", "", $after_from); ! eregi("GROUP +BY(.*)", $after_from, $regs); ! $group_by_fields = $regs[1]; ! $after_from = eregi_replace("GROUP +BY.*", "", $after_from); ! $count_query = "SELECT COUNT(DISTINCT $group_by_fields) AS COUNT_OF_RECS $after_from"; ! } ! else if (eregi("SELECT +DISTINCT", $before_from)) ! { ! $before_from = eregi_replace("SELECT +(DISTINCT.*)", "SELECT COUNT(\\1) AS COUNT_OF_RECS", $before_from); ! $count_query = $before_from.$after_from; ! } ! else ! { ! $count_query = "SELECT COUNT(1) AS COUNT_OF_RECS" . $after_from; ! } ! return $count_query; ! } } ?> \ No newline at end of file Index: class.MySQLCnn.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.MySQLCnn.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** class.MySQLCnn.php 14 Jul 2004 14:45:41 -0000 1.8 --- class.MySQLCnn.php 22 Jul 2004 16:25:38 -0000 1.9 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 35,42 **** function MySQLCnn($host =DBHOST, $user =DBUSER, $passw =DBPASS, $db_name =DBNAME) ! { ! $this->cnn = mysql_pconnect($host, $user, $passw); ! mysql_select_db($db_name) or die("unable to select db"); ! } /** --- 36,43 ---- function MySQLCnn($host =DBHOST, $user =DBUSER, $passw =DBPASS, $db_name =DBNAME) ! { ! $this->cnn = mysql_pconnect($host, $user, $passw); ! mysql_select_db($db_name) or die("unable to select db"); ! } /** *************** *** 45,99 **** */ function exec_query($query) ! { ! $result = mysql_query($query, $this->cnn); ! $this->show_error($query); ! if ( ereg("Resource", $result) ) ! { ! //the query was a 'select' and has returned some records, ! //convert the results to a two dimentional table ! $table = $this->result2table($result); ! return $table; ! } ! else ! { ! //the query was a command (insert, delete, update, etc.) ! //and it has returned TRUE or FALSE indicating success or failure ! return $result; ! } ! } /** Convert the mysql $result to a two-dimentional table. */ function result2table(&$result) ! { ! if (!$result) ! { ! print WebApp::error_msg("Query was not executed successfully."); ! return; ! } ! $arr_result = array(); ! $i = 0; ! while ( $row = mysql_fetch_array($result, MYSQL_ASSOC) ) ! { ! while ( list($fld_name, $fld_value) = each($row) ) ! { ! if (!isset($fld_value)) $fld_value = NULL_VALUE; ! $arr_result[$i][$fld_name] = $fld_value; ! } ! $i++; //next row ! } ! mysql_free_result($result); ! return $arr_result; ! } function show_error($query = "") ! { ! if (mysql_errno()==0) return; //no error ! if (mysql_errno()==1062) return; //ignore this error ! if (mysql_errno()==1136) return; //ignore this error ! print "Query: '$query' <br /> \n"; ! print mysql_errno().": ".mysql_error()." <br /> \n"; ! } } ?> \ No newline at end of file --- 46,100 ---- */ function exec_query($query) ! { ! $result = mysql_query($query, $this->cnn); ! $this->show_error($query); ! if ( ereg("Resource", $result) ) ! { ! //the query was a 'select' and has returned some records, ! //convert the results to a two dimentional table ! $table = $this->result2table($result); ! return $table; ! } ! else ! { ! //the query was a command (insert, delete, update, etc.) ! //and it has returned TRUE or FALSE indicating success or failure ! return $result; ! } ! } /** Convert the mysql $result to a two-dimentional table. */ function result2table(&$result) ! { ! if (!$result) ! { ! print WebApp::error_msg("Query was not executed successfully."); ! return; ! } ! $arr_result = array(); ! $i = 0; ! while ( $row = mysql_fetch_array($result, MYSQL_ASSOC) ) ! { ! while ( list($fld_name, $fld_value) = each($row) ) ! { ! if (!isset($fld_value)) $fld_value = NULL_VALUE; ! $arr_result[$i][$fld_name] = $fld_value; ! } ! $i++; //next row ! } ! mysql_free_result($result); ! return $arr_result; ! } function show_error($query = "") ! { ! if (mysql_errno()==0) return; //no error ! if (mysql_errno()==1062) return; //ignore this error ! if (mysql_errno()==1136) return; //ignore this error ! print "Query: '$query' <br /> \n"; ! print mysql_errno().": ".mysql_error()." <br /> \n"; ! } } ?> \ No newline at end of file Index: class.EditableRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.EditableRS.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** class.EditableRS.php 13 Jul 2004 13:18:08 -0000 1.9 --- class.EditableRS.php 22 Jul 2004 16:25:38 -0000 1.10 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 31,39 **** { function EditableRS($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) ! { ! $this->StaticRS($id, $query, $conn); ! $this->type = "EditableRS"; ! $this->opened = ($query==UNDEFINED ? true : false); ! } /** --- 32,40 ---- { function EditableRS($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) ! { ! $this->StaticRS($id, $query, $conn); ! $this->type = "EditableRS"; ! $this->opened = ($query==UNDEFINED ? true : false); ! } /** *************** *** 43,87 **** */ function apply($fun_name) ! { ! for ($i=0; $i < $this->count; $i++) ! { ! $fun_name($this->contents[$i]); ! } ! } /** Sets a new value to the given field (in the current record). */ function setFld($fld_name, $fld_value) ! { ! if ($this->EOF()) ! { ! $msg = "EditableRS::setFld(): pointer is at EOF.\n"; ! print WebApp::error_msg($msg); ! return; ! } ! if ($this->BOF()) ! { ! $msg = "EditableRS::setFld(): pointer is at BOF.\n"; ! print WebApp::error_msg($msg); ! return; ! } ! $rec = &$this->contents[$this->pos]; ! if (!isset($rec[$fld_name])) ! { ! $msg = "EditableRS::setFld(): field '$fld_name' does not exist.\n"; ! print WebApp::error_msg($msg); ! return; ! } ! $rec[$fld_name] = $fld_value; ! } /** Changes some fields of the current recordset. */ function setFlds($arr_flds) ! { ! while (list($fld_name,$fld_value) = each($arr_flds)) ! { ! $this->setFld($fld_name,$fld_value); ! } ! } /** --- 44,88 ---- */ function apply($fun_name) ! { ! for ($i=0; $i < $this->count; $i++) ! { ! $fun_name($this->contents[$i]); ! } ! } /** Sets a new value to the given field (in the current record). */ function setFld($fld_name, $fld_value) ! { ! if ($this->EOF()) ! { ! $msg = "EditableRS::setFld(): pointer is at EOF.\n"; ! print WebApp::error_msg($msg); ! return; ! } ! if ($this->BOF()) ! { ! $msg = "EditableRS::setFld(): pointer is at BOF.\n"; ! print WebApp::error_msg($msg); ! return; ! } ! $rec = &$this->contents[$this->pos]; ! if (!isset($rec[$fld_name])) ! { ! $msg = "EditableRS::setFld(): field '$fld_name' does not exist.\n"; ! print WebApp::error_msg($msg); ! return; ! } ! $rec[$fld_name] = $fld_value; ! } /** Changes some fields of the current recordset. */ function setFlds($arr_flds) ! { ! while (list($fld_name,$fld_value) = each($arr_flds)) ! { ! $this->setFld($fld_name,$fld_value); ! } ! } /** *************** *** 90,125 **** */ function addRec($rec) ! { ! if ($this->count==0) //recordset empty ! { ! $this->count++; ! $this->contents[0] = $rec; ! $this->pos = 0; ! return; ! } ! //for a non-empty recordset ! for ($i=$this->count; $i > ($this->pos+1); $i--) ! { ! $this->contents[$i] = $this->contents[$i-1]; ! } ! if (!$this->BOF()) ! { ! $this->contents[$i] = $this->contents[$i-1]; ! } ! $this->count++; ! $this->pos++; ! if ($this->EOF()) $this->pos--; ! $this->setFlds($rec); ! } function addRecs($arr_recs) ! { ! for ($i=0; $i < sizeof($arr_recs); $i++) ! { ! $rec = $arr_recs[$i]; ! $this->addRec($rec); ! } ! } /** --- 91,126 ---- */ function addRec($rec) ! { ! if ($this->count==0) //recordset empty ! { ! $this->count++; ! $this->contents[0] = $rec; ! $this->pos = 0; ! return; ! } ! //for a non-empty recordset ! for ($i=$this->count; $i > ($this->pos+1); $i--) ! { ! $this->contents[$i] = $this->contents[$i-1]; ! } ! if (!$this->BOF()) ! { ! $this->contents[$i] = $this->contents[$i-1]; ! } ! $this->count++; ! $this->pos++; ! if ($this->EOF()) $this->pos--; ! $this->setFlds($rec); ! } function addRecs($arr_recs) ! { ! for ($i=0; $i < sizeof($arr_recs); $i++) ! { ! $rec = $arr_recs[$i]; ! $this->addRec($rec); ! } ! } /** *************** *** 128,182 **** */ function insRec($rec) ! { ! if ($this->count==0) //recordset empty ! { ! $this->count++; ! $this->contents[0] = $rec; ! $this->pos = 0; ! return; ! } ! //for a non-empty recordset ! for ($i=$this->count; $i > ($this->pos + 1); $i--) ! { ! $this->contents[$i] = $this->contents[$i-1]; ! } ! if (!$this->BOF()) ! { ! $this->contents[$i] = $this->contents[$i-1]; ! } ! $this->count++; ! if ($this->BOF()) $this->pos++; ! $this->setFlds($rec); ! } function insRecs($arr_recs) ! { ! for ($i=0; $i < sizeof($arr_recs); $i++) ! { ! $rec = $arr_recs[$i]; ! $this->insRec($rec); ! } ! } /** Append the content of the given $rs to $this RS. */ function append($rs) ! { ! $pos = $this->pos; ! $this->MoveLast(); ! $rs->MoveFirst(); ! while (!$rs->EOF()) ! { ! $rec = $rs->Fields(); ! $this->addRec($rec); ! $rs->MoveNext(); ! } ! $this->pos = $pos; ! } function rmRec() ! { ! $this->rmRecs(1); ! } /** --- 129,183 ---- */ function insRec($rec) ! { ! if ($this->count==0) //recordset empty ! { ! $this->count++; ! $this->contents[0] = $rec; ! $this->pos = 0; ! return; ! } ! //for a non-empty recordset ! for ($i=$this->count; $i > ($this->pos + 1); $i--) ! { ! $this->contents[$i] = $this->contents[$i-1]; ! } ! if (!$this->BOF()) ! { ! $this->contents[$i] = $this->contents[$i-1]; ! } ! $this->count++; ! if ($this->BOF()) $this->pos++; ! $this->setFlds($rec); ! } function insRecs($arr_recs) ! { ! for ($i=0; $i < sizeof($arr_recs); $i++) ! { ! $rec = $arr_recs[$i]; ! $this->insRec($rec); ! } ! } /** Append the content of the given $rs to $this RS. */ function append($rs) ! { ! $pos = $this->pos; ! $this->MoveLast(); ! $rs->MoveFirst(); ! while (!$rs->EOF()) ! { ! $rec = $rs->Fields(); ! $this->addRec($rec); ! $rs->MoveNext(); ! } ! $this->pos = $pos; ! } function rmRec() ! { ! $this->rmRecs(1); ! } /** *************** *** 187,222 **** */ function rmRecs($nr =UNDEFINED) ! { ! if ( ($nr===UNDEFINED) or ! ($this->pos + $nr > $this->count) ) ! { ! //set $nr to the number of all remaining ! //recs up to the EOF (including the current rec) ! $nr = $this->count - $this->pos; ! } ! //get the number of the remaining elements ! //from the current rec up to the EOF ! $rem = $this->count - $this->pos - $nr; ! //move up all the recs that will remain ! for ($i=0; $i < $rem; $i++) ! { ! $i1 = $this->pos + $i; //new position ! $i2 = $this->pos + $i + $nr; //old position ! if ($i1 >= 0) //at BOF, $this->pos is -1 ! { ! $this->contents[$i1] = $this->contents[$i2]; ! } ! } ! //delete the last recs ! for ($i=$this->pos+$rem; $i < $this->count; $i++) ! { ! unset($this->contents[$i]); ! } ! //update the count of the recs ! $this->count -= $nr; ! } /** --- 188,223 ---- */ function rmRecs($nr =UNDEFINED) ! { ! if ( ($nr===UNDEFINED) or ! ($this->pos + $nr > $this->count) ) ! { ! //set $nr to the number of all remaining ! //recs up to the EOF (including the current rec) ! $nr = $this->count - $this->pos; ! } ! //get the number of the remaining elements ! //from the current rec up to the EOF ! $rem = $this->count - $this->pos - $nr; ! //move up all the recs that will remain ! for ($i=0; $i < $rem; $i++) ! { ! $i1 = $this->pos + $i; //new position ! $i2 = $this->pos + $i + $nr; //old position ! if ($i1 >= 0) //at BOF, $this->pos is -1 ! { ! $this->contents[$i1] = $this->contents[$i2]; ! } ! } ! //delete the last recs ! for ($i=$this->pos+$rem; $i < $this->count; $i++) ! { ! unset($this->contents[$i]); ! } ! //update the count of the recs ! $this->count -= $nr; ! } /** *************** *** 225,236 **** */ function addCol($fld_name, $default_value =UNDEFINED) ! { ! if (isset($this->contents[0][$fld_name])) return; ! for ($i=0; $i < $this->count; $i++) ! { ! $this->contents[$i][$fld_name] = $default_value; ! } ! } /** --- 226,237 ---- */ function addCol($fld_name, $default_value =UNDEFINED) ! { ! if (isset($this->contents[0][$fld_name])) return; ! for ($i=0; $i < $this->count; $i++) ! { ! $this->contents[$i][$fld_name] = $default_value; ! } ! } /** *************** *** 238,256 **** */ function renameCol($fld_name, $new_fld_name) ! { ! if (isset($this->contents[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->contents[$i][$new_fld_name] = $this->contents[$i][$fld_name]; ! unset($this->contents[$i][$fld_name]); ! } ! } } ?> \ No newline at end of file --- 239,257 ---- */ function renameCol($fld_name, $new_fld_name) ! { ! if (isset($this->contents[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->contents[$i][$new_fld_name] = $this->contents[$i][$fld_name]; ! unset($this->contents[$i][$fld_name]); ! } ! } } ?> \ No newline at end of file Index: class.Connection.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.Connection.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** class.Connection.php 25 Aug 2003 13:18:32 -0000 1.7 --- class.Connection.php 22 Jul 2004 16:25:38 -0000 1.8 *************** *** 1,30 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - - /** - * This class is used for opening a connection with a database - * and for executing a query. This is like an interface, which - * is implemented by DB specific classes. - * - * @package database - */ class Connection { --- 1,23 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ class Connection { *************** *** 41,47 **** function Connection($host =DBHOS... [truncated message content] |