[phpwebapp-commits] CVS: web_app/database package.DB.php,1.3,1.4 class.TableRS.php,1.3,1.4 class.Sta
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2003-08-23 02:58:48
|
Update of /cvsroot/phpwebapp/web_app/database In directory sc8-pr-cvs1:/tmp/cvs-serv6393/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: modified a little bit the comments Index: package.DB.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/package.DB.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** package.DB.php 11 Aug 2003 16:17:52 -0000 1.3 --- package.DB.php 22 Aug 2003 15:54:42 -0000 1.4 *************** *** 8,12 **** switch (DB_TYPE) { - default: case "MySQL": $CnnType = "MySQLCnn"; --- 8,11 ---- *************** *** 16,19 **** --- 15,19 ---- case "ProgreSQL": case "SQLServer": + default: print "Sorry, DB_TYPE='".DB_TYPE."' is not implemented yet.<br>\n"; break; *************** *** 27,35 **** include_once DB_PATH."class.TableRS.php"; ! //Create a default connection for the application. Parameters ! //of this connection are specified in 'config/const.DB.php'. ! //This connection will be used for each interaction with a DB, ! //if no other connection is specified. The application, however, ! //can create and use other connections as well, or override this one. $cnn = new $CnnType; } --- 27,37 ---- include_once DB_PATH."class.TableRS.php"; ! /** ! * Create a default connection for the application. Parameters ! * of this connection are specified in 'config/const.DB.php'. ! * This connection will be used for each interaction with a DB, ! * if no other connection is specified. The application, however, ! * can create and use other connections as well, or override this one. ! */ $cnn = new $CnnType; } Index: class.TableRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.TableRS.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** class.TableRS.php 11 Aug 2003 16:17:52 -0000 1.3 --- class.TableRS.php 22 Aug 2003 15:54:42 -0000 1.4 *************** *** 10,16 **** * @package database */ ! class TableRecordset extends Recordset { ! function TableRecordset() { } --- 10,16 ---- * @package database */ ! class TableRS extends EditableRS { ! function TableRS() { } Index: class.StaticRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.StaticRS.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** class.StaticRS.php 11 Aug 2003 16:17:52 -0000 1.3 --- class.StaticRS.php 22 Aug 2003 15:54:42 -0000 1.4 *************** *** 13,17 **** class StaticRS extends Recordset { ! var $opened; /** true when the recordset is opened */ function StaticRS($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) --- 13,18 ---- class StaticRS extends Recordset { ! /** true when the recordset is opened */ ! var $opened; function StaticRS($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) *************** *** 33,41 **** } ! function Close() ! { ! //override the Close() of superclass ! //with an empty function ! } } ?> --- 34,42 ---- } ! /** ! * Override the Close() of superclass ! * with an empty function. ! */ ! function Close() {} } ?> Index: class.Recordset.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.Recordset.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** class.Recordset.php 11 Aug 2003 16:17:52 -0000 1.5 --- class.Recordset.php 22 Aug 2003 15:54:42 -0000 1.6 *************** *** 5,10 **** * connection with a database. If no connection is specified, then * it uses the global connection of the framework: $cnn. - * In case of modifying the class for a DB other than MySQL, only - * the function result2table() needs to be changed. * * @package database --- 5,8 ---- *************** *** 12,25 **** class Recordset { ! var $ID; //the ID of the Recordset (usually the same as the ID of the template) ! var $query; //query as string (may contain {{variables}}) ! var $cnn; //the connection that will execute the query ! var $content; //the result after executing the query (2 dimensional array) ! var $pos; //the current position in the array $content ! var $count; //the number of rows in the array $content ! var $type; //the type of the recordset: Recordset, PagedRS, ! //StaticRS, DynamicRS, EditableRS, TableRS function EOF() --- 10,32 ---- class Recordset { ! /** The ID of the Recordset. */ ! var $ID; ! ! /** The type of the recordset: Recordset, PagedRS, ! * StaticRS, DynamicRS, EditableRS, TableRS */ ! var $type; ! /** Query as string (may contain {{variables}}). */ ! var $query; ! /** The connection that will execute the query. */ ! var $cnn; ! /** The result after executing the query (2 dimensional array). */ ! var $content; ! /** The current position in the array $content. */ ! var $pos; ! /** The number of rows in the array $content, */ ! var $count; ! function EOF() *************** *** 53,57 **** } ! /** returns the value of the field given as parameter */ function Field($fld_name) { --- 60,64 ---- } ! /** Returns the value of the field given as parameter. */ function Field($fld_name) { *************** *** 62,66 **** } ! /** returns all the fields at the current position as an associated array */ function Fields() { --- 69,73 ---- } ! /** Returns all the fields at the current position as an associated array. */ function Fields() { *************** *** 68,72 **** } ! /** constructor */ function Recordset($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) { --- 75,79 ---- } ! /** Constructor */ function Recordset($id =UNDEFINED, $query =UNDEFINED, $conn =UNDEFINED) { *************** *** 82,86 **** } ! /** executes the query and puts the result into $this->content */ function Open($q =UNDEFINED) { --- 89,93 ---- } ! /** Executes the query and puts the result into $this->content. */ function Open($q =UNDEFINED) { *************** *** 113,118 **** /** ! * returns a new recordset that contains a slice of this recordset; ! * see the documentation of array_slice of PHP */ function slice($offset =0, $length =UNDEFINED) --- 120,125 ---- /** ! * Returns a new recordset that contains a slice of this recordset. ! * @see array_slice */ function slice($offset =0, $length =UNDEFINED) *************** *** 139,147 **** /** ! * returns true if the query at the given position * matches the $condition (usually used by the functions ! * find() and filter() above); if no position is given ! * matches the current record; ! * currently the $condition supports only one field */ function match($condition, $pos=UNDEFINED) --- 146,155 ---- /** ! * Returns true if the query at the given position * matches the $condition (usually used by the functions ! * find() and filter()). If no position is given ! * matches the current record. ! * Currently the $condition supports only one field. ! * @see find(), filter() */ function match($condition, $pos=UNDEFINED) *************** *** 173,181 **** /** ! * returns a new recordset with the recs that match the * given condition, $condition is like the WHERE condition * of a query, but it matches using regexp-s, e.g. ! * (username=/^d.* / AND (firstname=/[^a]+/ OR NOT lastname='Hoxha')) ! * (currently it supports only one field, no AND, OR, (, ) etc.) */ function filter($condition) --- 181,190 ---- /** ! * Returns a new recordset with the recs that match the * given condition, $condition is like the WHERE condition * of a query, but it matches using regexp-s, e.g. ! * <kbd>(username=/^d.*a/ AND (firstname=/[^a]+/ OR NOT lastname='Hoxha'))</kbd> ! * ! * @todo Currently it supports only one field, no AND, OR, (, ) etc. */ function filter($condition) *************** *** 196,205 **** /** ! * finds the subset of the recordset that matches the * condition and positions the pointer to the first ! * record found; $condition is like the condition in filter(); ! * if called without parameter, if finds the next one, ! * and so on up to EOF; returns false if it couldn't find ! * another record */ function find($condition =UNDEFINED) --- 205,215 ---- /** ! * Finds the subset of the recordset that matches the * condition and positions the pointer to the first ! * record found. $condition is like the condition in filter(). ! * If called without parameter, if finds the next one, ! * and so on up to EOF. Returns false if it couldn't find ! * another record. ! * @see filter() */ function find($condition =UNDEFINED) *************** *** 210,216 **** /** ! * used by find(), finds all the records that match * the condition and stores their indeces in ! * the array $this->found_positions */ function search($condition) --- 220,227 ---- /** ! * Used by find(), finds all the records that match * the condition and stores their indeces in ! * the array $this->found_positions. ! * @see find() */ function search($condition) *************** *** 228,234 **** /** ! * used by find(), sets $this->pos to the next * found record; returns true if found, ! * or false if there are no more records */ function find_next() --- 239,246 ---- /** ! * Used by find(), sets $this->pos to the next * found record; returns true if found, ! * or false if there are no more records. ! * @see find() */ function find_next() *************** *** 248,252 **** } ! /** returns an array with the values of the specified field */ function getColumn($fld_name) { --- 260,264 ---- } ! /** Returns an array with the values of the specified field. */ function getColumn($fld_name) { *************** *** 263,269 **** /** ! * $fld_names is a comma separated list of field names; ! * returns a new recordset that contains only the specified ! * columns */ function getColumns($fld_names) --- 275,280 ---- /** ! * Returns a new recordset that contains only the specified ! * columns. $fld_names is a comma separated list of field names. */ function getColumns($fld_names) Index: class.PagedRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.PagedRS.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** class.PagedRS.php 11 Aug 2003 16:17:52 -0000 1.4 --- class.PagedRS.php 22 Aug 2003 15:54:42 -0000 1.5 *************** *** 5,9 **** * Same as class Recordset, but gets from the DB only a certain * page out of all the results that can return the query. A page ! * is a group of consecutive records, all the pages have the same * number of records and they form a partition of the results. * --- 5,9 ---- * Same as class Recordset, but gets from the DB only a certain * page out of all the results that can return the query. A page ! * is a group of consecutive records; all the pages have the same * number of records and they form a partition of the results. * *************** *** 12,20 **** class PagedRS extends Recordset { ! /** how many recs will be read from DB for one page ! * if 0 then all the recs will be read in one page */ var $recs_per_page; ! var $current_page; //which page will be read (starting from 1) ! var $nr_of_recs; //nr of all the recs that can return the query function PagedRS($id, $query =UNDEFINED, $rp =UNDEFINED, $conn =UNDEFINED) --- 12,27 ---- class PagedRS extends Recordset { ! /** ! * How many recs will be read from DB for one page, ! * if 0 then all the recs will be read in one page ! */ var $recs_per_page; ! ! /** Which page will be read (starting from 1). */ ! var $current_page; ! ! /** Number of all the recs that can return the query. */ ! var $nr_of_recs; ! function PagedRS($id, $query =UNDEFINED, $rp =UNDEFINED, $conn =UNDEFINED) *************** *** 27,32 **** /** ! * get and return the state var ! * for the current page of this recordset */ function get_current_page() --- 34,39 ---- /** ! * Get and return the state var ! * for the current page of this recordset. */ function get_current_page() *************** *** 41,45 **** } ! /** executes the query and puts the result into $this->content */ function Open($cp ="default", $rp ="default", $query ="default") { --- 48,52 ---- } ! /** Executes the query and puts the result into $this->content. */ function Open($cp ="default", $rp ="default", $query ="default") { *************** *** 73,77 **** /** ! * returns an array of some variables that can be used in the * template to indicate the next page, previous page, etc. */ --- 80,84 ---- /** ! * Returns an array of some variables that can be used in the * template to indicate the next page, previous page, etc. */ *************** *** 150,153 **** --- 157,161 ---- * which gets the number of records of the original query. * Called by $this->get_nr_of_recs(). + * @see get_nr_of_recs() */ function get_count_query($query) Index: class.MySQLCnn.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.MySQLCnn.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** class.MySQLCnn.php 20 Aug 2003 06:57:45 -0000 1.5 --- class.MySQLCnn.php 22 Aug 2003 15:54:42 -0000 1.6 *************** *** 43,47 **** } ! /** convert the mysql $result to a two-dimentional table */ function result2table(&$result) { --- 43,47 ---- } ! /** Convert the mysql $result to a two-dimentional table. */ function result2table(&$result) { *************** *** 70,74 **** 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 --- 70,74 ---- 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 *************** *** 76,79 **** print mysql_errno().": ".mysql_error()." <br> \n"; } ! } //end class Connection ?> --- 76,79 ---- print mysql_errno().": ".mysql_error()." <br> \n"; } ! } ?> Index: class.EditableRS.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.EditableRS.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** class.EditableRS.php 11 Aug 2003 16:17:52 -0000 1.4 --- class.EditableRS.php 22 Aug 2003 15:54:42 -0000 1.5 *************** *** 18,24 **** /** ! * applies the function $fun_name on each record ! * of the recordset; $fun_name is a global function ! * that takes as parameter an associated array by reference */ function apply($fun_name) --- 18,24 ---- /** ! * Applies the function $fun_name on each record ! * of the recordset. $fun_name is a global function ! * that takes as parameter an associated array by reference. */ function apply($fun_name) *************** *** 30,34 **** } ! /** Sets a new value to the given field (in the current record) */ function setFld($fld_name, $fld_value) { --- 30,34 ---- } ! /** Sets a new value to the given field (in the current record). */ function setFld($fld_name, $fld_value) { *************** *** 56,60 **** } ! /** changes some fields of the current recordset */ function setFlds($arr_flds) { --- 56,60 ---- } ! /** Changes some fields of the current recordset. */ function setFlds($arr_flds) { *************** *** 66,71 **** /** ! * adds a new record after the current record, ! * the new record becomes current */ function addRec($rec) --- 66,71 ---- /** ! * Adds a new record after the current record, ! * the new record becomes current. */ function addRec($rec) *************** *** 104,109 **** /** ! * insert a new record before the current record, ! * the new record becomes the current record */ function insRec($rec) --- 104,109 ---- /** ! * Insert a new record before the current record; ! * the new record becomes the current record. */ function insRec($rec) *************** *** 140,146 **** } ! /** ! * Append the content of the given $rs to $this RS ! */ function append($rs) { --- 140,144 ---- } ! /** Append the content of the given $rs to $this RS. */ function append($rs) { *************** *** 163,172 **** /** ! * removes $nr recs from the recordset, ! * starting with the current record; ! * if $nr is not given or exeeds the EOF, ! * then removes all the recs up to the EOF */ ! function rmRecs($nr=UNDEFINED) { if ( ($nr===UNDEFINED) or --- 161,170 ---- /** ! * Removes $nr recs from the recordset, ! * starting with the current record. ! * If $nr is not given or exeeds the EOF, ! * then removes all the recs up to the EOF. */ ! function rmRecs($nr =UNDEFINED) { if ( ($nr===UNDEFINED) or Index: class.Connection.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.Connection.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** class.Connection.php 20 Aug 2003 06:57:45 -0000 1.5 --- class.Connection.php 22 Aug 2003 15:54:42 -0000 1.6 *************** *** 9,12 **** --- 9,13 ---- class Connection { + /** The connection to the DB. */ var $cnn; |