Browse database records [RFC]

From: Date: Tue, 30 Oct 2001 13:38:18 +0000
Subject: Browse database records [RFC]
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-2438@lists.php.net to get a copy of this message
Hi! If there is some interest I'd like to commit the attached classes to the PEAR CVS. These classes are for displaying grids of data, e.g. browsing database records. The most advanced class DBGrid does page handling and sorting of selected columns automatically. The classes are based on the DB and IntegratedTemplate classes. They currently still have my class prefix "IFW_" (=IntranetFrameWork). I'd like to have comments - especially about the class names and whether and where to put the classes in the PEAR tree. class description ----------------------------------------------------------------- URL URL helper class. Used to create the URLs for page browsing and sorting DBSelect Classes for generating "select" database statements. DBSelect_common This abstraction layer was necessary because different DBSelect_mssql databases sometimes need different statements. When DBSelect_mysql changing the sort criteria (ORDER BY) by the DBGrid this should be universal. Another reason for this class was the fact, that some database drivers have problems returning the number of rows of a query. So these classes implement a "getCount" method which will return a "SELECT COUNT(*)..." statement. Grid Abstract base class for Grids. StringGrid Displaying a table from an array DBGrid Displaying a table from a DB and a "select" statement. The sources are in alpha state, contain rough documentation and they should match the PEAR Coding Standard. A basic usage looks like that: $db = DB::connect("odbc://user:password@database"); $stmt = IFW_DBSelect::create('mssql'); $stmt->addField("*"); $stmt->addTable("sa_user"); $stmt->addFilter("username LIKE 'a%'"); $grid = new IFW_DBGrid($db, $stmt, "F:/templatelocation", "userlist.tpl"); $grid->show(); A basic template: <html> <body> Rows {ROWMIN}-{ROWMAX} of {ROWCOUNT}, Page {PAGENO} of {PAGENOMAX} <table border=1> <tr> <th>&nbsp;</th> <th><a href="{URL_SORT_USERNAME}">Username</a></th> <th><a href="{URL_SORT_SURNAME}">Full Name</a></th> <th>Org. unit</th> <th>Location</th> </tr> <!-- BEGIN listrow --> <tr> <td>{ROWNO}</td> <td><a href="{URL_BASE}?module=user&action=edit&userid={USERID}">{USERNAME}</a></td> <td>{PRENAME} {SURNAME}</td> <td>{ORGUNITNAME}</td> <td>{LOCATIONNAME}</td> </tr> <!-- END listrow --> </table> <!-- BEGIN prevpage --> <a href="{URL_PREVPAGE}">[&lt;&lt;]</a><br> <!-- END prevpage --> <!-- BEGIN nextpage --> <a href="{URL_NEXTPAGE}">[&gt;&gt;]</a><br> <!-- END nextpage --> </body> </html>

« previous php.pear.dev (#2438) next »